用原型怎么实现两个文本框同时执行
对原型还不理解!:confused:[html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head>
<body>
<input type="text" id="newslist_01" value="" />
<hr />
<input type="text" id="newslist_02" value="" />
<script type="text/javascript">
function tdhy(elem,n){
_this = this;
this.ID = document.getElementById(elem);
this.I = 0;
this.N = n;
setInterval(function(){_this.scroll()},1000);
}
tdhy.prototype.scroll=function(){
this.I += this.N;
this.ID.value = this.I;
}
new tdhy("newslist_01",1);
new tdhy("newslist_02",2);
</script>
</body>
</html>
[/html]
[[i] 本帖最后由 caiying2007 于 2008-8-29 12:23 编辑 [/i]] [html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head>
<body>
<input type="text" id="newslist_01" value="" />
<hr />
<input type="text" id="newslist_02" value="" />
<hr />
<input type="text" id="newslist_03" value="" />
<script type="text/javascript">
function tdhy(elem,n){
this.ID = document.getElementById(elem);
this.I = 0;
this.N = n;
this.scroll(this);
}
tdhy.prototype.scroll=function(obj){
setInterval(function(){obj.doScroll()},1000);
}
tdhy.prototype.doScroll=function(){
this.I += this.N;
this.ID.value = this.I;
}
new tdhy("newslist_01",1);
new tdhy("newslist_02",2);
new tdhy("newslist_03",3);
</script>
</body>
</html>
[/html]
[[i] 本帖最后由 caiying2007 于 2008-8-29 12:25 编辑 [/i]]
页:
[1]