<ul>
<li><a href="#">one</a></li>
<li><a href="#">two</a></li>
<li><a href="#">three</a></li>
</ul>
我想只显示一个li
使用幻灯片效果,这就是它。我想避免使用插件来实现像这样简单的事情。简单的代码(jQuery)
在此先感谢您的帮助。
<ul>
<li><a href="#">one</a></li>
<li><a href="#">two</a></li>
<li><a href="#">three</a></li>
</ul>
我想只显示一个li
使用幻灯片效果,这就是它。我想避免使用插件来实现像这样简单的事情。简单的代码(jQuery)
在此先感谢您的帮助。
我做了一些简单的为您(基于在您的描述),只是为了指出你在正确的方向:
看看这里: http://jsfiddle.net/meo/ACenH/234/
function slider(container, delay){
$container = $(container) // select the container elements and store them in a variable
if (!$container.length){ return fasle; } // checks if the slider exists in your dom. if not the function ends here...
var slides = $container.length, // gives back the total LI's you have
slide = 0 // set the actual li to show
setInterval(function(){ // set a Interval for your main function
if (slide == slides - 1) { // if the actual slide is equal the total slides (-1 because eq is 0 based and length gives back the number of elements in the jQuery object) the slide counter is set to 0
$container.slideDown(); // and all slides a shown again
slide = 0;
} else {
$container.eq(slide).slideUp(); //slides the selected slide up i think you could think of a solution with .next() instead of eq()
slide++; // slide counter +1
}
}, delay)
}
slider('ul > li', 2000); // call your slider function
错字3,'fasle' – 2013-12-24 04:19:14
你的问题已经提到jQuery作为选择的JavaScript框架。你就可以开始的最好的地方是隐藏的jQuery的文档:
和滑动:
http://api.jquery.com/slideUp/
http://api.jquery.com/slideDown/
http://api.jquery.com/slideToggle/
尝试elancer或租来的编码器 – Quentin 2010-05-10 07:50:22
我觉得他是用租来的编码器,并获得报酬这一点;) – Konerak 2010-05-10 08:02:04
SO不一样了我猜。我问过很多类似的问题,总是得到帮助,但也许那些人已经离开,你已经到了?无论如何,我自己想出了一个解决方案。 – 3zzy 2010-05-10 10:43:16