I am trying to do an off-canvas sidebar and I am using the .toggleClass function to make it active or not. When it is active I would like the button (.btn) to say "hide" and when it is not say "show". I have already tried to do an if statement and it has failed. I have also looked at other stackoverflow questions with no success. Can anybody help with how to detect a class has been toggled or not?
$(document).ready(function () {
$('[data-toggle="offcanvas"]').click(function () {
$('.row-offcanvas').toggleClass('active');
// if active "hide"
$('.btn').html("HIDE");
// if not active "show"
$('.btn').html("SHOW");
});
});
.btnis inside or next to the.row-offcanvas, I'd just use CSS.