【问题标题】:java script Vertical news ticker doesn't workjavascript垂直新闻行情不工作
【发布时间】:2014-03-18 06:05:35
【问题描述】:

我有一个像这样的 html sn-p:

<div>
<div>&nbsp;</div>
<div class="news">
<ul id="listticker">
 <li><b>"Lorem Ipsum is a dummy text used by designers from all over the world. While writing Lorem ipsum you dont need worry grammar about and splleing mistkae. You get complete freedome of writing anything you want. I love Lorem Ipsum so much. .</li>
 <li><b>"Lorem Ipsum is a dummy text used by designers from all over the world. While writing Lorem ipsum you dont need worry grammar about and splleing mistkae. You get complete freedome of writing anything you want. I love Lorem Ipsum so much. </li>
 <li><b>"Lorem Ipsum is a dummy text used by designers from all over the world. While writing Lorem ipsum you dont need worry grammar about and splleing mistkae. You get complete freedome of writing anything you want. I love Lorem Ipsum so much. . </li>
</ul>
</div>
</div>

我在哪里调用了这样的 news_ticker 脚本

<script src="js/news_ticker.js" type="text/javascript"></script>

代码如下

$(document).ready(function () {

    var first = 0;
    var speed = 800;
    var pause = 3500;

    function removeFirst() {
        first = $('ul#listticker li:first').html();
        $('ul#listticker li:first')
.animate({ opacity: 0, height: "0px" }, speed, 'linear', function () { $(this).remove(); });
        addLast(first);
    }

    function addLast(first) {
        last = '<li style="display:none">' + first + '</li>';
        $('ul#listticker').append(last)
        $('ul#listticker li:last')
.animate({ opacity: 1, height: "auto" }, speed)
.fadeIn('slow')
    }
        interval = setInterval(removeFirst, pause);
});

为什么我的股票根本不滚动?

【问题讨论】:

  • 我确实在jsfiddle.net/NeR8Z 看到了一些滚动。这不是预期的效果吗?控制台有错误吗?
  • 对我来说似乎也可以。
  • 我只是尝试在 Jsfiddle(jsfiddle.net/PVD7F)
  • @loxxy..还有其他方法可以完成相同的任务吗?它在我的网页中不起作用..在 jsfiddle 中运行良好!尝试了所有方法!
  • @mmu 你是否包含了 jQuery?你们有现场演示吗?

标签: javascript jquery html css news-ticker


【解决方案1】:

你的代码运行良好,可能你的 jQuery 库版本太旧了。我用 jQuery v2.0.3 测试它

【讨论】:

  • 我确实更新了 jQuery 库,现在它可以正常工作了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-17
  • 1970-01-01
相关资源
最近更新 更多