求写一个停止移动的函数,大神来求我啊...苦逼新手 本帖最后由 u014790351 于 2014-05-03 21:36:14 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用clearTimeout()模仿这个例子写吧http://www.w3school.com.cn/tiy/t.asp?f=hdom_timing_stop 给你var dom, x, y, finalx = 300,t;function initText() { debugger; dom = document.getElementById('theText').style; var x = dom.left.replace('px',''); moveText(x);}function moveText(x) { x++; if (x < finalx){ dom.left = x + "px"; t = setTimeout("moveText(" + x + ")", 1); } if (x == finalx){ moveTextR(x); }else { return false; }}function moveTextR(x) { if(x>=0){ x--; dom.left = x + "px"; if (x == 0) { moveText(x); } t = setTimeout("moveTextR(" + x + ")", 1); } }function stopMove(){ clearTimeout(t) }<!DOCTYPE html><html lang = "en"> <head> <title> Moving text </title> <meta charset = "utf-8" /> <style type = "text/css"> #theText {position: absolute; left:0px; top:0px; font: bold 1.7em 'Times Roman'; color: blue;} </style> <script type = "text/javascript" src = "moveText.js"> </script> </head> <body><!-- The text to be moved --> <p> <span id = 'theText'> Jump in the lake! </span> </p> <br /><br /><br /><br /><br /><br /><br /><br /><br /> <br /><br /><br /><br /><br /><br /><br /><br /><br /><!-- Control Moving --> <input type="button" value="START MOVING" onclick="initText()"> <input type="button" value="STOP MOVING" onclick="stopMove();"> 这里,求一个写一个停止移动文字的函数 </body></html> extjs form1.add(textfired fd)这样添加的控件界面上取不到它的信息 请教js中+new Date的作用 火狐的firebug如何修改javascript代码 js日期格式化 关于javascript连接数据库的字符串 jquery给.net 服务端控件赋值 有怎么在后台取值啊 ??? extjs布局问题 怎么判断按下的是哪个按钮?? 急求!! 怎样实现刷新网页后的左右滚动条的位置不变 请问:如何判断客户端是否已安装了某一控件(OCX)? 登陆界面的实现 SyntaxHighlighter插件怎么实现,异步预览高亮
http://www.w3school.com.cn/tiy/t.asp?f=hdom_timing_stop
var dom, x, y, finalx = 300,t;
function initText() {
debugger;
dom = document.getElementById('theText').style;
var x = dom.left.replace('px','');
moveText(x);
}function moveText(x) {
x++;
if (x < finalx){
dom.left = x + "px";
t = setTimeout("moveText(" + x + ")", 1);
}
if (x == finalx){
moveTextR(x);
}else {
return false;
}
}function moveTextR(x) {
if(x>=0){
x--;
dom.left = x + "px";
if (x == 0) {
moveText(x);
}
t = setTimeout("moveTextR(" + x + ")", 1);
}
}function stopMove(){
clearTimeout(t)
}
<!DOCTYPE html>
<html lang = "en">
<head>
<title> Moving text </title>
<meta charset = "utf-8" />
<style type = "text/css">
#theText {position: absolute; left:0px; top:0px;
font: bold 1.7em 'Times Roman';
color: blue;}
</style>
<script type = "text/javascript" src = "moveText.js">
</script>
</head>
<body>
<!-- The text to be moved -->
<p>
<span id = 'theText'> Jump in the lake!
</span>
</p> <br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br />
<!-- Control Moving -->
<input type="button" value="START MOVING" onclick="initText()">
<input type="button" value="STOP MOVING" onclick="stopMove();"> 这里,求一个写一个停止移动文字的函数
</body>
</html>