So what I'm trying to do is sort of like the thumbs up/thumbs down voting system on youtube using jquery, implying that once a user has voted, both divs(images, doesn't matter what) will become unavailable for that specific post.
So far, to do so, I use a .click() inside which a toggleClass() will change its own class, I can see that the class changes if I inspect the DOM, but why is the .click() still working on the new class ?
//TO BE CALLED WHEN USER CLICKS VOTE FORGIVENESS
$('.voteUp').click(function() {
var id = $(this).closest("article").attr("id");
//Make it impossible to vote again
$(this).toggleClass('voteUp votedUp');
$(this).parent().find('.voteDown').toggleClass('voteDown votedDown');
});
And my html (php)
<article class='yellowSheet' id='57'>
<div class="title">
<h1>StuffUp says :</h1>
<p class="story">What happened ?</p>
</div>
<div class="entryContent">
<p>guy, 2011-06-28 17:11:48</p>
</div>
<div class="voting">
<img class="voteUp" src="images/thumbsUp.png" /></div>
<img class="voteDown" src="images/thumbsDown.png" /></div>
<div class="storyBottom"></div>
</article>
What I don't understand is why after toggling class, I still can click on the new class-"votedDown" since that class doesn't have a .click method ?
Thank You