我想做的是改变一个对象的属性,但只针对那个。因此,$('.up img').attr("src","img/up.png")
对于已单击的元素,并非所有具有.up img
.
jQuery:
$('.up img').click( function(){
var postDataUp = $(this).attr('mod');
$.post('/votePost.php', {varUp: postDataUp}, function(o){
console.log(o);
if(o == 1){
$('.up img').attr("src","img/up.png");
}else if(o == 2){
$('.up img').attr("src","img/up-g.png");
$('.down img').attr("src","img/dw.png");
}else if(o == 3){
$('.up img').attr("src","img/up.png");
}
}, 'json');
});