So I am trying to get the text in the button to toggle between strings stored in the data attributes:
<button class="toggleButton6 book1" data-starttext="Starting Text" data secondtext="Toggled Text">Starting Text</button>
So far I can get the text to change only for the first click event. I need to add something to get the text to toggle back and forth with unlimited click events:
$(document).ready(function(){
$('.book1').on('click', function(){
var textVariable = $(this).data("secondtext");
$(this).text(textVariable);
});
});
data secondtext. Should bedata-secondtext