$(this).siblings("property2").hide().child("select").attr("disabled","disabled");
这应该访问单击按钮的同级“property2”并将其隐藏。之后它将访问“property2”的子“select”并将禁用属性添加到“select”。
但这不起作用。请帮助...谢谢!
$(this).siblings(".property2").hide().children("select").attr("disabled","disabled");
child
应该替换为children()
如果您正在使用,property2
那么您正在尝试选择带有标签 name 的元素property2
。如果你想通过类名访问,那么它将是.property2
.
如果要删除 disabled 属性,则可以使用.removeAttr("disabled")
假设这property2
是一个类,并且 select 是该元素的直接后代:
$(this)
.siblings('.property2')
.hide()
.children("select")
.attr("disabled","disabled");
$(this).siblings(".property2").hide().children().attr("disabled","disabled");
做到了……^^