1 回答

TA貢獻1824條經驗 獲得超5個贊
你可以做到jquery
第一步
改變這個
//select all checkboxes
<th><input type="checkbox" class=""/></th>
對此
//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!
第三步
在頁腳中添加這個
<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 這對你有用……
- 1 回答
- 0 關注
- 108 瀏覽
添加回答
舉報