Collapse events are used to show the alerts when the click function is pressed
<div class="container"> <h2>Collapsible Events</h2> <button type="button" class="btn btn-success">Show</button> <button type="button" class="btn btn-warning">Hide</button> <div class="collapse"> TechFunda is a online tutorial </div> </div> <script> $(document).ready(function () { $(".btn-success").click(function () { $(".collapse").collapse('show'); }); $(".btn-warning").click(function () { $(".collapse").collapse('hide'); }); $(".collapse").on('show.bs.collapse', function () { alert('The collapsible content is about to be shown.'); }); $(".collapse").on('shown.bs.collapse', function () { alert('The collapsible content is now fully shown.'); }); $(".collapse").on('hide.bs.collapse', function () { alert('The collapsible content is about to be hidden.'); }); $(".collapse").on('hidden.bs.collapse', function () { alert('The collapsible content is now hidden.'); }); }); </script>
btn-success
and btn-warning
collapse
btn-success
and btn-warning
to show and hide the content, we have different events to show the alert.on('show.bs.collapse', function ())
-It displays the alert before opening the content.on('shown.bs.collapse', function())
- It displays the alert after opening the content.on('hide.bs.collapse', function())
-It displays the alert before closing the content.on('hidden.bs.collapse', function())
- It displays the alert after closing the contentoutput
Views: 20740 | Post Order: 51