jQuery   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了JQuery,在jsfiddle工作的li元素的衰落循环,但不在现场大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在jsfiddle中使用以下代码http://jsfiddle.net/S5Cjm/1242/

function InOut(elem) {
var delayOn = 2000,// time each <li> should be visible
    delayOff = 0,// time between revealing each <li>
    fade = 1000; // fade duration

// Pause,fade in,pause again,fadeout,then fire the callback
elem.delay(delayOff).fadeIn(fade).delay(delayOn).fadeOut(function() {
    // If we're not on the last <li>
    if (elem.next().length > 0) {
        // Call InOut on the next <li>
        InOut(elem.next());
    }
    else {
        // Else go back to the start
        InOut(elem.siblings(':first'));
        }
    });
}

$(function() {
    // Hide all the li's
    $('#content li').hide();
    // Call InOut to loop through them
    InOut($('#content li:first'));
});

但是,当嵌入到我的代码中时,它不起作用.

我在脑中引用JQuery:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

它曾莫名其妙地工作过一次,尽管复制了代码,但仍然没有.

任何帮助非常感谢!

解决方法

这对我有用:=)你的代码没有错,除了你忘了将它包装在$(document).ready(function(){})中;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<Meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<Meta name="author" content=""/>
<Meta name="description" content=""/>
<Meta name="keywords" content=""/>
<title></title>
<style type="text/css">
*{margin:0px;padding:0px}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"   type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
//alert('workin');
    function InOut(elem) {
    var delayOn = 2000,then fire the callback
   elem.delay(delayOff).fadeIn(fade).delay(delayOn).fadeOut(function() {
    // If we're not on the last <li>
    if (elem.next().length > 0) {
        // Call InOut on the next <li>
        InOut(elem.next());
    }
    else {
        // Else go back to the start
        InOut(elem.siblings(':first'));
    }
    });
    }

    $(function() {
    // Hide all the li's
    $('#content li').hide();
    // Call InOut to loop through them
    InOut($('#content li:first'));
    });
    });
   </script>
   </head>
   <body>
       <ul id="content">
       <li>first</li>
       <li>second</li>
       <li>third</li>
       <li>fourth</li>
       <li>fifth</li>
       <li>sixth</li>
       </ul>
   </body>
   </html>

大佬总结

以上是大佬教程为你收集整理的JQuery,在jsfiddle工作的li元素的衰落循环,但不在现场全部内容,希望文章能够帮你解决JQuery,在jsfiddle工作的li元素的衰落循环,但不在现场所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: