复选框上的事件没有发生

时间:2017-04-16 22:01:51

标签: javascript jquery

我有一系列复选框,我正在运行以下操作,但它从未发生过,控制台没有结果

jQuery( ".masonry input[checkbox]" ).on("change", function() {
  if(jQuery(this).is(":checked")) {
    console.log("changed");
    jQuery('#terzo').removeAttr("disabled");
  }
});

HTML

<div class="masonry">
    <div class="item">
        <input type="checkbox" name="thing_1" value="valuable" id="thing_1">
            <label for="thing_1">
                <img class="img-responsive" src="http://independentskies.com/wp-content/uploads/2013/11/428126-3732x2655.jpg">
            </label>
        </div>
        <div class="item">
                <input type="checkbox" name="thing_2" value="valuable" id="thing_2">
            <label for="thing_2">
        <img class="img-responsive" src="http://viajescasaquinta.com/wp-content/uploads/2016/11/Grecia.jpg">
    </label>
</div>

1 个答案:

答案 0 :(得分:2)

data$Error不是选择"input[checkbox]"元素的有效css选择器。使用<input type="checkbox">