http://jsfiddle.net/thetylercox/gy8EQ/20/
$(':checkbox').change(function() {
if (this.checked) {
var lastChecked = $(this).prevAll(":checked:first");
if (this.value == lastChecked.val()) {
alert("previous checked box has same value");
}
}
});
问题是它只能从右向左尝试另一个方向?如果值不相等,则尝试执行 if (this.value != lastChecked.val()) { alert("previous check box has same value"); }