0
我有这个代码的问题:https://jsfiddle.net/vitordhers/fm8a14x6/2/如何连接变量与选择器?
我打算让子类,如果出现至少一个复选框被选中,但是当我取消选中的复选框,子类别不会消失,因为它们与其他类别的班级共享同一班级。
为了将代码应用到一个段落而已,我试图以连接$这个选择有:检查选择,但它似乎并没有工作:
$("p").click(function() {
var $line = $('.l' + $(this).data('value'));
var n = $($this+"input:checked").length;
alert(n);
if(n == 0){
$($line).hide(); //if there are none checked, hide visible elements
} else {
$($line).show(); //otherwise (some are selected) fadeIn - if the div is hidden.
}
});
任何人可以帮我在这案件?在此先感谢
'$ this'未定义。 – DarthJDG
如果你试图找到一个子项目,那么'$(“input:checked”,this)' –
注意,不要执行'$($ line)'。它已经是一个jQuery对象。 – Taplar