jQuery addClass() task, or how to use index instead of ID
Hi everyone,
i have this code:
-
$(document).ready(function() {
var element = $(".mainSubNav ul li a");
element.mouseover(function() {
idLi = $(this).attr("id");
$(".mainSubNav ul li a#" + (parseInt(idLi) - 1)).addClass("bgNone2");
}).mouseout(function() {
$(".mainSubNav ul li a#" + (parseInt(idLi) - 1)).removeClass("bgNone2");
});
});
how can I change it that it will be catching index of LI A elements, instead of ID's ?? because I don't want to use ID's for A elements if I can use index "[0,1,3,...,i]" of LI or A elements
thx a lot for help... If this explanation is not enough, let me know, I will try to explain it with further information