简体   繁体   中英

jQuery ticker works in jsfiddle, but it doesn't work in .HTML

I have this jQuery newsticker that works in jsFiddle, but if I transfer it to an HTML file, it doesn't work any more. Everything is exactly the same, but it doesn't work which is weird.

Here's the jsFiddle: http://jsfiddle.net/RXH6w/9/

$.noConflict();
jQuery( document ).ready(function( $ ) {
    function NewsTickerAutoPlay() {
        $(".NewsTicker li:first-child").slideUp(function () {
            $(this).appendTo(".NewsTicker").fadeIn();
        });
    }
    setInterval(function () {
        NewsTickerAutoPlay()
    }, 1000);
});

And here's the HTML that I copied from my jsFiddle: http://jehzlau.net/ticker.html

Everything is copied exactly the same, but it doesn't work in my HTML. I hope someone here can trace my simple problem.

Update your HTML with the code below. Remember by adding "/show" at the end of the JSFiddle URL will lead you the whole page everything in it.

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Simple NewsTicker - jsFiddle demo</title>

  <script type='text/javascript' src='/js/lib/dummy.js'></script>




  <link rel="stylesheet" type="text/css" href="/css/result-light.css">


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


  <style type='text/css'>
    .NewsTicker {
    list-style-type:none;
    margin:0;
    padding:0;
    line-height:20px;
    height:20px;
    overflow:hidden
}
  </style>



<script type='text/javascript'>//<![CDATA[ 
window.onload=function(){
$.noConflict();
jQuery( document ).ready(function( $ ) {

function NewsTickerAutoPlay() {
    $(".NewsTicker li:first-child").slideUp(function () {
        $(this).appendTo(".NewsTicker").fadeIn();
    });
}

setInterval(function () {
    NewsTickerAutoPlay()
}, 1000);

});
}//]]>  

</script>


</head>
<body>
  <ul class="NewsTicker">
<li>Etisalat and Huawei Conduct First 400G Trial Optical Transport Network in Middle East and North Africa</li>
<li>Huawei to Deploy Africa's First Smart eLTE Urban Railway Communications System in Ethiopia</li>
</ul>

</body>


</html>

您在“ text / javascript”中缺少一个“ a ”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM