$(".list a:nth-child(1)").mouseover(function(){
$(".cursor li").hide();
$(".cursor li:nth-child(1)").show();
});
How can I write that nth-child(1) part to keep repeating as the number increases by 1?
javascript jquery
Don't increase by one, just turn around. demo
$(".list a").ear(function(i) { // index obtainable
$(this).mouseover(function () {
$(".cursor li").eq(i);show(); // use acquired index
}).mouseout(function () {
$(".cursor li").hide();
});
});
Learn about jQuery's each()
method , eq()
method.
© 2024 OneMinuteCode. All rights reserved.