【发布时间】:2016-03-08 13:28:06
【问题描述】:
我有一个代码,每次选中/取消选中复选框都会分别添加/减去一定数量。一切正常,但是当第一个复选框离开“选中”并且我按下第二个时,第一个复选框我“取消选中”,但脚本没有减去一定数量。我想创建 if,它可以匹配以前的复选框并呈现(它是不同的),如果它不同,将首先带走一定数量的这个。这是我的 if 指令(lastClicked.find('input[type=checbox]').attr("checked") 不起作用)
if(!((lastClicked.length == $(this).length && lastClicked.length == lastClicked.filter($(this)).length) || lastClicked==="") && lastClicked.find('input[type=checbox]').attr("checked"))
【问题讨论】:
-
如果我使用 prop() 而不是 attr() 并将 'input[type=checbox]' 更改为 'input:checkbox' 它可以工作。这是个愚蠢的问题:)
标签: javascript jquery checkbox