- `遍历 each
$("input[name='supplyProtocolType']").each(function (){
var str = $(this).val();
if (str == supplyProtocolType) {
$(this).attr("checked",true);
}
});
//选中状态
$("#id input[name='supplyProtocolType']:checked").each(function (){
var str = $(this).val();
if (str == supplyProtocolType) {
$(this).attr("checked",true);
}
});
2 禁用 父节点 下所有符合条件 input框节点
$('#id input[name='protocol']').attr("disabled", "disabled");
$("#id input").removeAttr("disabled");
$("#id input").prop("disabled");// 删除属性 和removeAttr 有区别
本文介绍使用jQuery进行DOM元素遍历与属性操作的方法,包括如何遍历并设置复选框的选中状态,以及如何禁用和启用输入框。通过具体代码示例展示了jQuery在网页元素操作上的便捷性和灵活性。
1697

被折叠的 条评论
为什么被折叠?



