I need help adding a new Bootstrap 4 accordion when a button is clicked. Can someone assist me with implementing this feature in jQuery? I'm not sure if it's possible to add accordions dynamically using jQuery.
<script>
$(document).ready(function(){
$('#addAccordion').click( function() {
var newDiv = "<div class='card'> <div class='card-header'> <a class='card-link' data-toggle='collapse' href='#collapseOne'>
Collapsible Group Item #1</a>
</div>
<div id='collapseOne' class='collapse show' data-parent='#accordion'>
<div class='card-body'>Lorem ipsum dolor sit amet,</div> </div> </div>";
$('.display').append(newDiv);
});
});
</script>
<div id="accordion">
<div class="card">
<div class="card-header">
<a class="card-link" data-toggle="collapse" href="#collapseOne">
Collapsible Group Item #1
</a>
</div>
<div id="collapseOne" class="collapse show" data-parent="#accordion">
<div class="card-body">
Lorem ipsum dolor sit amet,
</div>
</div>
</div>
</div>
<div class="display"> </div>
<button id="addAccordion">Add new accordion</button>