Javascript 此脚本在运行时停止

Javascript 此脚本在运行时停止,javascript,jquery,html,css,marquee,Javascript,Jquery,Html,Css,Marquee,var reset = function() { $(this).css("margin-top", "100%"); $(this).animate({ "margin-top": "0%" }, 5000, 'linear', reset); }; html片段是 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict

var reset = function() {
    $(this).css("margin-top", "100%");
    $(this).animate({ "margin-top": "0%" }, 5000, 'linear', reset);
};
html片段是

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
<head>

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

<style type="text/css">
</style>

</head>
<body>


  <div id="marquee"><p>My scrolling text is so freakin' COOL!!!111!</p><p>My scrolling text is so freakin' COOL!!!111!</p
<p>My scrolling text is so freakin' COOL!!!111!</p</div>


</body>
</html>
var reset = function() {
    $(this).css("margin-top", "100%");
    $(this).animate({ "margin-top": "0%" }, 5000, 'linear', reset);
};


我的滚动文字太酷了!!!111!

我的滚动文本太酷了!!!111!请注意,
reset
函数中的
这个
已经是一个jQuery对象,因此您不需要包装在选择器调用中
this.css()
this.animate()
就足够了。谢谢,但这会从屏幕中间开始并重新启动文本
var reset = function() {
    $(this).css("margin-top", "100%");
    $(this).animate({ "margin-top": "0%" }, 5000, 'linear', reset);
};