ページを読み込んだ後にチェックボックスをクリックしてすべてのチェックボックスを選択する方法。jQueryでページを読み込んだ後にすべてのチェックボックスをチェック
私のhtmlコードは、
<table id="dealer_select_list" class="table table-bordered table-striped">
<thead>
<tr>
<th>Id</th>
<th>Customer Name</th>
<th><input id="selectall" type="checkbox">Select All</th>
</tr>
</thead>
<tbody id="Dlist_cont">
</tbody>
</table>
残りのチェックボックスは、ボタンのクリック後に表示されます。私は、チェックボックスは、ページのロードの後に登場していると思うので、コードは、
$list .= "<td><input id='checkBox' class='checkbox' type='checkbox' value='{$dl['id']}'></td>";
私のjqueryのコードは、
$('#selectall').click(function() {
if (this.checked) {
$(':checkbox').each(function() {
this.checked = true;
});
} else {
$(':checkbox').each(function() {
this.checked = false;
});
}
});
このコードは動作していないされています。どうすればこの問題を解決できますか?
あなたのHTMLを表示しますか? –
私は – Arya
の上にhtmlコードを追加しました$(document).ready(funtion(){})でコードを取りますか? – Tomato32