Expand-Collapse Function on click

We can expand or collapse a div by clicking a button by adding a class “show”

<button type=”button” id=”button-id”>Expand-Collapse</button>
<div id=”content”>
  <p>The content to display… </p>
</div>

<script>

$( ‘#button-id’ ).on( ‘click’, function(e){
jQuery(‘#content’).toggleClass(‘show’);
});

</script>

Leave a comment

Your email address will not be published. Required fields are marked *