简体   繁体   中英

Bootstrap 4 Checkbox accordion not working

I want to create like this.

https://getbootstrap.com/docs/4.0/components/collapse/#multiple-targets

But I put to replace button to checkbox. I want to when checked the checkbox. It collapse

<div class="container-fluid">
    <b>درخواست شغل</b>
    <div class="row">
        <div class="col-md-12">
            <div class="form-group">
                <label for="change_jobs">قصد انتخاب یا تغییر شغل دارم</label>
                <input type="checkbox" id="change_jobs" name="change_jobs" data-toggle="collapse" onclick="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
                <div class="collapse" id="collapseExample">
                    <div class="card card-body">
                        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

When I click the checkbox I see this error in console and It did not open

SyntaxError: private fields are not currently supported

Replace onclick="#collapseExample" with data-target="#collapseExample"

<div class="container-fluid">
    <b>درخواست شغل</b>
    <div class="row">
        <div class="col-md-12">
            <div class="form-group">
                <label for="change_jobs">قصد انتخاب یا تغییر شغل دارم</label>
                <input type="checkbox" id="change_jobs" name="change_jobs" data-toggle="collapse" data-target="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
                <div class="collapse" id="collapseExample">
                    <div class="card card-body">
                        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

I hope this will be helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM