<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>模拟事件操作</title>
<script src="../js/jquery-3.3.1.js"></script>
<script>
$(function(){
$("input:button").click(function(){
var index=0;
//启动定时器,2s打个分
//触发当前文本框的光标切入事件(onfocus)
var id=setInterval(function(){
$("input:text").eq(index).trigger("focus");
var score=parseInt(Math.random()*100);
$("input:text").eq(index).val(score);
index++;
},2000);
if(index==$("input:text").length){
clearInterval(id);
}
});
});
</script>
</head>
<body>
<p>
<input type="button" value="打分"/>
</p>
<p>
张三:<input type="text"/>
</p>
<p>
李四:<input type="text"/>
</p>
<p>
王五:<input type="text"/>
</p>
<p>
赵六:<input type="text"/>
</p>
<p>
周七:<input type="text"/>
</p>
</body>
</html>
jQuery模拟事件操作
最新推荐文章于 2023-05-17 13:59:24 发布