简体   繁体   English

jQuery ticker在jsfiddle中可用,但在.HTML中不起作用

[英]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. 我有一个可在jsFiddle中使用的jQuery newsticker,但如果将其传输到HTML文件,它将不再起作用。 Everything is exactly the same, but it doesn't work which is weird. 一切都是一样的,但是那很奇怪,这是行不通的。

Here's the jsFiddle: http://jsfiddle.net/RXH6w/9/ 这是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 这是我从jsFiddle复制的HTML: http ://jehzlau.net/ticker.html

Everything is copied exactly the same, but it doesn't work in my HTML. 一切都被完全复制,但是在我的HTML中不起作用。 I hope someone here can trace my simple problem. 我希望这里有人可以追踪到我的简单问题。

Update your HTML with the code below. 使用以下代码更新您的HTML。 Remember by adding "/show" at the end of the JSFiddle URL will lead you the whole page everything in it. 请记住,在JSFiddle URL的末尾添加“ / show”将引导您整个页面中的所有内容。

<!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 ”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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