1 回答

TA貢獻(xiàn)1824條經(jīng)驗(yàn) 獲得超5個(gè)贊
你可以做到j(luò)query
第一步
改變這個(gè)
//select all checkboxes
<th><input type="checkbox" class=""/></th>
對(duì)此
//select all checkboxes
<th><input type="checkbox" class="check_all"/></th> //just added a class to this element
第二步
將 class_name 添加到所有<input type="checkbox"> 我的意思<input type="checkbox" id="message_{{$message->id}}" name="message" value="{{$message->id}}">更改為<input type="checkbox" id="message_{{$message->id}}" name="message" value="{{$message->id}}" class="custom_name">
筆記: be sure that all your checkboxes has one class_name instead the one witch if we click it others checked!
第三步
在頁(yè)腳中添加這個(gè)
<script
src="https://code.jquery.com/jquery-3.4.1.js"
integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
crossorigin="anonymous"></script>
<script>
$(".check_all").on("click", function(){
$(".custom_name").each(function(){
$(this).attr("checked", true);
});
});
</script>
我 HPOE 這對(duì)你有用……
- 1 回答
- 0 關(guān)注
- 105 瀏覽
添加回答
舉報(bào)