I have the following piece of code I need in order to update a bootstrap button when a collapsed is opened or closed. However the icon part is updating but impossible to get the button text updated and I have no idea why.
My javascript level is very low and I'm simply using part of code I might find on SOF or anywhere else on internet.
Javascript
$('#more-properties').on('hidden.bs.collapse', function () {
var icon = document.getElementById("icon-more-properties");
icon.setAttribute('class', 'fas fa-angle-down pr-2');
var btn = document.getElementById("btn-more-properties");
btn.textContent('More properties');
});
$('#more-properties').on('shown.bs.collapse', function () {
var icon = document.getElementById("icon-more-properties");
icon.setAttribute('class', 'fas fa-angle-up pr-2');
var btn = document.getElementById("btn-more-properties");
btn.textContent('Less properties');
});
Bootstrap button
<div class="col-12 text-center" id="btn-div">
<button class="btn btn-outline-dark shadow-none collapsed" id="btn-more-properties" type="button" data-toggle="collapse" data-target="#more-properties" style="border-radius: 0 !important;">
<i id="icon-more-properties" class="fas fa-angle-down pr-2"></i>More properties</button>
</div>
Does anyone can tell me why it is not working ? I can't find any similar issue on iternet.
Thank you in advance for your help.
id="btn-more-properties"? If so, that is not allowed.id, at all times and cost, must be unique, per-document.