setInterval 实时驱动界面改变

时间:2023-12-25 11:11:31
 <!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>
<script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
</head>
<body>
输 入 值:<input type="text" id="inputValue" value="0" />
<br />
实时改变:<input type="text" id="inputChangeValue" value="0" />
</body>
</html>
<script type="text/javascript">
function setTxtValue() {
var value = parseInt($("#inputValue").val())
$("#inputChangeValue").val(value)
}
var shTime;
$(document).ready(function () {
$("#inputValue").focus(function () {
shTime = setInterval(setTxtValue, 100);
});
$("#inputValue").blur(function () {
clearInterval(shTime);
});
});
</script>

附件下载:http://files.cnblogs.com/Orange-C/demo.rar