iterating through and showing hidden child divs jquery
我有埃多克斯1〔0〕。每个
标记都将css设置为
标记,将段落的可见性更改为
1 2 3 4 5 | $('#content').children('p').each(function() { $(this).css('visibility', 'visible'); //delay before continuing iteration }); |
CSS:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #content { position: absolute; font-size: 25px; width: 50%; top: 20%; left: 5%; -moz-animation-duration: 2s; -moz-animation-delay: 1s; -moz-animation-iteration-count: 1; } p { -moz-animation-duration: 1s; -moz-animation-delay: 2s; -moz-animation-iteration-count: 1; visibility: hidden; } |
当我是什么understood from the title,你需要它与JQ,你可以使用这个代码 </P >
1 2 3 4 5 | $('#content').children('p').each(function (index, elem) { setTimeout(function () { $(elem).css({visibility: 'visible'}); }, 500 * index); }); |
http:/ / / / 3 jsfiddle.net tvz039nk / </P >
作为"tasos suggested, </P >
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | var __OBJECTS = []; $('#content').children('p').each(function() { __OBJECTS.push($(this)); }); addPositioningClasses(); function addPositioningClasses() { var $card = __OBJECTS.shift(); $card.css('visibility', 'visible'); if (__OBJECTS.length) { setTimeout(addPositioningClasses, 500) } } |
伟大的作品。 </P >