setInterval 实时驱动界面改变
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 5 <title>实时驱动界面改变</title> 6 <script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script> 7 </head> 8 <body> 9 输 入 值:<input type="text" id="inputValue" value="0" /> 10 <br /> 11 实时改变:<input type="text" id="inputChangeValue" value="0" /> 12 </body> 13 </html> 14 <script type="text/javascript"> 15 function setTxtValue() { 16 var value = parseInt($("#inputValue").val()) 17 $("#inputChangeValue").val(value) 18 } 19 var shTime; 20 $(document).ready(function () { 21 $("#inputValue").focus(function () { 22 shTime = setInterval(setTxtValue, 100); 23 }); 24 $("#inputValue").blur(function () { 25 clearInterval(shTime); 26 }); 27 }); 28 </script>
作者:Orange.
出处:http://www.cnblogs.com/Orange-C/
声明:本博客原创文字只代表本人工作中在某一时间内总结的观点或结论,与本人所在单位没有直接利益关系。非商业,未授权,贴子请以现状保留,转载时必须保留此段声明,且在文章页面明显位置给出原文连接。
如果大家感觉我的博文对大家有帮助,请推荐支持一把,给我写作的动力。
。