I will try to answer your question by showing how you can improve your jQuery code and how to solve your problem in one go! :)
First, you can simplify your code by refactoring .css() calls in one call. This will make all the code run faster, since you will not iterate over the same element for every .css() call.
So part of the code will come from
$("#interest"+i).hover(function() { $("#interest"+i).css("width","115%") .css("height","70px") .css("margin-left","-10px"); },function() { $("#interest"+i).css("width","95%") .css("height","56px") .css("margin-left","3px"); });
to
$("#interest"+i).hover(function() { $("#interest"+i).css({ "width":"115%", "height":"70px", "margin-left":"-10px" }); },function() { $("#interest"+i).css({ "width":"95%", "height":"56px", "margin-left":"3px" }); });
and finally, Adil beat me before that, you can bind the hover event to the class instead. And after his advice with selectors is also very good! :)
Hope this helps some! :)
source share