gpt4 book ai didi

javascript - 简单的股票代码 (jQuery)

转载 作者:行者123 更新时间:2023-11-28 14:04:11 25 4
gpt4 key购买 nike

<ul>
<li><a href="#">one</a></li>
<li><a href="#">two</a></li>
<li><a href="#">three</a></li>
</ul>

我想使用幻灯片效果一次仅显示一个li,仅此而已。我想避免使用插件来完成这样简单的事情。

预先感谢您的帮助。

最佳答案

我为您做了一些简单的事情(根据您的描述),只是为了给您指出正确的方向:

在这里查看: 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

关于javascript - 简单的股票代码 (jQuery),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2801072/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com