I have an output of DIV elements created through Javascript that looks like this.
<div class="span3">
<div class="filter"><i class="icon-stop"></i>User 1</div>
</div>
<div class="span3">
<div class="filter"><i class="icon-stop"></i>User 2</div>
</div>
<div class="span3">
<div class="filter"><i class="icon-stop"></i>User 3</div>
</div>
Below is the snippet of JS I have to toggle a class on click
$(".filter").on("click", function() {
console.log("User is clicked");
$(this).toggleClass("alert");
});
Can anyone point out to me why the on click is not triggering? and the class not getting applied to the clicked DIV element?