首页 > 代码库 > setInterval 实时驱动界面改变

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="http://www.mamicode.com/Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>  7 </head>  8 <body>  9 输 入 值:<input type="text" id="inputValue" value="http://www.mamicode.com/0" /> 10 <br /> 11 实时改变:<input type="text" id="inputChangeValue" value="http://www.mamicode.com/0" /> 12 </body> 13 </html> 14 <script type="text/javascript"> 15 function setTxtValue() { 16 var value = http://www.mamicode.com/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> 

 


 

 

setInterval 实时驱动界面改变