是否有类似于 HTML 中的 disabled
和 hidden
的 show
和 enabled
属性。
我有一个使复选框禁用
和隐藏
的场景
示例:我有 3 个同一组的复选框,分别为 JAN、FEB 和 MAR。 1. 单击 JAN 禁用 FEB 并 2. JAN 的 Onclick 使 MAR 隐藏。
以上示例的输出请查看下面的屏幕截图。
用于隐藏和禁用的 Jquery 脚本
$("input:checkbox").change(function() {
var t = $(this).parents("form:first");
function ischecked(c) {
var count = 0;
if ($("input#f79uim").is(":checked")) {
count++;
}
if (count > 0) {
return true;
} else {
return false;
}
}
if (ischecked("f79uim")) {
if ("hidden" == "hidden") {
t.find("input#fsmafx").prop("hidden", !0);
t.find("input#fsmafx").parent().hide();
}
if ("hidden" == "disabled") {
t.find("input#fsmafx").prop("disabled", !0);
$("input#fsmafx").attr('c-disabled-by', 'f79uim');
}
if ("hidden" == "hidden") {
$("input#fsmafx").attr('c-hidden-by', 'f79uim');
}
if ($("select#fsmafx")) {
$("select#fsmafx").prop("disabled", !0);
$("select#fsmafx").attr('c-disabled-by', 'f79uim');
}
}
同样,为什么不使用 show
和 enabled
属性?
最佳答案
显示属性使用
t.find("input#fsmafx").prop("hidden", 0);
t.find("input#fsmafx").parent().show();
并启用属性使用
t.find("input#fsmafx").prop("disabled", 0);
关于jquery - HTML 属性 "disabled"和 "hidden",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50921225/