2017-04-16 28 views
0

我有一系列的复选框,我运行下面的,但它永远不会发生,并且控制台没有给出结果事件上的复选框不会发生

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> 
+0

显示您的HTML。 '$(document).ready()'中的代码? – Barmar

+0

@Barmar你去,用html更新quetsion,如果有需要的话 –

回答

2

"input[checkbox]"不一个有效的css选择器来选择<input type="checkbox">元素。使用"input[type=checkbox]"

+1

或者jQuery的缩写':checkbox' – Barmar

+0

注意''css'' input [type =“checkbox”]需要双引号包围属性值' – guest271314

+0

我不认为他们是,除非类型包含空间或其他特殊字符。 – Barmar