第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

復(fù)選框選擇所有復(fù)選框 Laravel

復(fù)選框選擇所有復(fù)選框 Laravel

PHP
開滿天機(jī) 2022-07-22 16:37:14
這是我的問題:在 PHP Laravel 中,我有一個(gè) foreach 循環(huán),它在屏幕上顯示消息,包括一個(gè)復(fù)選框。每條消息都有自己的復(fù)選框。我在所有消息的頂部還有一個(gè)復(fù)選框。我想為該復(fù)選框分配一個(gè)功能以檢查所有復(fù)選框。我知道過去曾有人問過這個(gè)問題,但不幸的是,這些答案對(duì)我不起作用。有人對(duì)我有解決方案嗎?我正在使用:Laravel、Inspinia、Bootstrap 4提前致謝!這是我的代碼:@if(count($messages) > 0)        <table class="table table-hover">            <thead>                <tr>                    <th>&nbsp;</th>                    //select all checkboxes                    <th><input type="checkbox" class=""/></th>                    <th>@sortablelink('title', trans('messages.title'))</th>                    <th>@sortablelink('sender_user_id', trans('messages.sender'))</th>                    <th class="d-none d-sm-table-cell">@sortablelink('created_at', trans('messages.sent_at'))</th>                </tr>            </thead>            <tbody>            @foreach ($messages as $message)                <tr id="messagesTable">                    <td><i class="{{ $message->read ? 'far fa-envelope-open' : 'fas fa-envelope' }}"></i></td>                    //the checkboxes who need to be selected                    <td class="project-title">                        <div class="checkbox p1-1">                             <input type="checkbox" id="message_{{$message->id}}" name="message" value="{{$message->id}}">                            <label for="message_{{$message->id}}"></label>                        </div>                    </td>        </table>@endif
查看完整描述

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ì)你有用……


查看完整回答
反對(duì) 回復(fù) 2022-07-22
  • 1 回答
  • 0 關(guān)注
  • 105 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)