I'm new to JavaScript and have used the primary post about how to toggle classes from here: Change an element's class with JavaScript but for some reason my code is not executing like I would expect it to. The code is placed in the bottom of an HTML file.
<script>
$(document).ready(function () {
$('.arrow').addEventListener('click', function() {
if (this.hasClass('glyphicon-chevron-right')) {
this.addClass('glyphicon-chevron-left');
this.removeClass('glyphicon-chevron-right');
}
if (this.hasClass('glyphicon-chevron-left')) {
this.addClass('glyphicon-chevron-right');
this.removeClass('glyphicon-chevron-left');
}
}, false);
});
</script>