0

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?

Prabhu Murthy
  • 9,031
  • 5
  • 29
  • 36
BaconJuice
  • 3,739
  • 13
  • 56
  • 88
  • Works fine http://jsfiddle.net/Jr6NZ/ – imbondbaby Jul 28 '14 at 14:28
  • maybe, you don't add jQuery library or do that after implementing your script. – Ivan Ivanov Jul 28 '14 at 14:29
  • That's very strange. @IvanIvanov I add the Jquery Library correctly. Any other ideas? Also running jquery version 1.9.1 – BaconJuice Jul 28 '14 at 15:46
  • Also I don't understand why this question was closed? I already checked that solution before and as the code showed it was already using the given solution? so this is a different question and not a duplicate? – BaconJuice Jul 28 '14 at 15:48
  • Please, provide your code. If you were using same solution as in ref. and it didn't work, please, mention that. There are so many duplicated and stupid questions that every new question is supposed to be duplicated, until it described properly. – Ivan Ivanov Jul 29 '14 at 03:09

0 Answers0