I'm having trouble attaching a click function to a really simple bit of jquery, basically what I'm doing is hiding a bunch of li's then fading them in, I can get it working on documentready when the pages is loaded, but I can't get the function to increment the fade in's when it's attached to a click.
$(document).ready(function () {
$(".extra-holder ul li").hide().each(function (i) {
var delayInterval = 1000; // milliseconds
$(this).delay(i * delayInterval).fadeIn();
});
});
This works perfectly, fading them in 1 second increments.
What I wanted to do was bind it to a click event, this 'works', but it doesn't increment the fade in's, they all just pop in at the same time.
$(document).ready(function () {
$(".extra-holder ul li").hide().each(function (i) {
var delayInterval = 1000; // milliseconds
$('.extra-related').click(function () {
$(".extra-holder ul li").delay(i * delayInterval).fadeIn();
});
});
});
Correct answer(removed hiding on click):-
$(document).ready(function () {
$(".extra-holder ul li").hide();
var delayInterval = 300;
$('.extra-related').click(function () {
$(".extra-holder ul li").each(function (i) {
$(this).delay(i * delayInterval).fadeIn();
});
});
});