why this click function still works
Hello all, I am new to this forum and also I don't have experience on jquery.
I load a file after clicking in one div, I remove class when this click happen, but still if I click on this div execute to load the file.
the script is
- <script type="text/javascript">
$(function(){
$(".up").addClass("votes");
$(".down").addClass("votes");
//<![CDATA[
$(".votes").click(function() {
var id = $(this).attr("id");
var name = $(this).attr("name");
var data = 'name='+ name;
var parent = $(this);
if(id=='up'){
$(this).fadeIn(600).html('Thank you');
$.ajax({
type: "POST",
url: 'up.php',
data: data,
cache: false,
success: function(html){
parent.html(html);
$(".votes").removeClass('votes');
$(".up").addClass("votes3");
}
});
}else{
$(this).fadeIn(600).html('Thank you');
$.ajax({
type: "POST",
url: 'down.php',
data: data,
cache: false,
success: function(html){
parent.html(html);
$(".votes").removeClass('votes')
$(".down").addClass("votes2");
}
});
}
return false;
});
//]]>
});
</script>
html
- <div class="up id="up"><?php echo'<a class="vote" id="voteup" name="up">'.$up.'</a>';?></div>
<div class="down id="down"><?php echo'<a class="vote" id="votedown" name="down">'.$down.'</a>';?></div>
with above script I add class .votes in divs up and down, so can click it, but although I remove the class .votes still I can click and load again the script.
Any idea what I am doing wrong?