My jQuery code is :
num=15;
$('#share_button_'+num).mouseover(function(){
$('#share_button_'+num).attr("src","img/share-hover.jpg");
});
$('#share_button_'+num).mouseout(function(){
$('#share_button_'+num).attr("src","img/share-button-en.jpg");
});
num=30;
$('#share_button_'+num).mouseover(function(){
$('#share_button_'+num).attr("src","img/share-hover.jpg");
});
$('#share_button_'+num).mouseout(function(){
$('#share_button_'+num).attr("src","img/share-button-en.jpg");
});
My problem is that only the last one (can be the 15 or the 30) works. Is is written inside an Ajax success response :
$.ajax({
async: true,
url: "myurl.php",
type: "POST",
data: "uid="+uid,
dataType: "html",
success: function (data, textStatus, xhr) {
//Written here
}
Why is this happening?
var div=new Array();
div[0]=15;
div[1]=96;
div[2]=30;
var i=2;
$('#share_button_'+div[i]).mouseover(function(){
$('#share_button_'+div[i]).attr("src","img/share-hover.jpg");
});
$('#share_button_'+div[i]).mouseout(function(){
$('#share_button_'+div[i]).attr("src","img/share-button-en.jpg");
});
var j=1;
$('#share_button_'+div[j]).mouseover(function(){
$('#share_button_'+div[j]).attr("src","img/share-hover.jpg");
});
$('#share_button_'+div[j]).mouseout(function(){
$('#share_button_'+div[j]).attr("src","img/share-button-en.jpg");
})