Look at the code below:
$(".head img").hover(function(){
var id = $(this).attr('id');
$(this).attr("src","images/"+id+"_hover.gif");
},function(){
var id = $(this).attr('id');
$(this).attr("src","images/"+id+".gif");
})
If I do not use the “id”,just use “this.indexof()” something like this.
the code below is wrong, but i want you to know what i mean:
$(".head .fl_r img").hover(function(){
$(this).attr("src","images/"+this.indexof(in array())+"_hover.gif");
},function(){
$(this).attr("src","images/"+this.indexof(in array())+".gif");
})
How can i do that in jquery?
I’d look into the jQuery
.eachmethod, as it provides an index.