【发布时间】:2014-06-12 17:32:38
【问题描述】:
我正在尝试使嵌套标签/复选框在其包含标签/复选框被选中时可见。我不知道如何定位特定的嵌套标签,或者这是否是正确的方法。
这是一个小提琴:
http://jsfiddle.net/kirkbross/tfKva/15/
这里是javascript:
$(".label-1").click(function() {
$("input:checkbox").each(function() {
if ($(this).prop("checked")) {
$(this).next('.label-2').show(); // can't figure out how to get at the second "nested" label
} else {
$(this).next('.label-2').hide();
}
});
});
【问题讨论】:
-
.show()在visibility:hidden;中不显示元素 -
同样对于您的 JSFiddle,您没有包含 jQuery,这意味着几乎什么都行不通!
标签: jquery checkbox nested label show