2017-04-16 44 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

相關問題