jQuery を使用してチェックされたボックスは、ハンドラーprop()
にアタッチされたリスナーには影響しません。change
私のコードは次のようなものです
HTML
<div>
<label>
<input type="checkbox" class="ch" />test</label>
<label>
<input type="checkbox" class="ch" />test</label>
<label>
<input type="checkbox" class="ch" />test</label>
<input type="button" value="check the box" id="select" />
</div>
JS
$("body").on("change", ".ch", function(){
alert("checked");
});
$("body").on("click", "#select", function(){
$(this).parent("div").find("input[type=checkbox]").prop("checked", true);
});
チェックボックスをクリックするとアラートが発生します。チェックボックスのプロパティが変更されたときに起動するにはどうすればよいですか? JSBIN