您现在的位置是:首页 > 学无止境> JS网站首页学无止境JS

jquery版提交表单10s内不可提交

jquery   表单  
简介jquery版提交表单10s内不可提交

<!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>jquery版提交表单10s内不可提交</title>
<script type=”text/javascript” src=”js/jquery.js”></script>
<script type=”text/javascript”>
$(document).ready(function(e) {
//1.默认进来不可点,10s可点
$(“button#btn1”).attr(“disabled”,true);
$(“button#btn1”).html(“开始操作(<span>10</span>秒)”);
setInterval(function(){
//timer=parseInt($(“span”).text());
timer=$(“#btn1 span”).text();
//alert(timer);
if (timer==0){
$(“button#btn1”).html(“点击进入网站”);
$(“button#btn1”).attr(“disabled”,false);
clearInterval(timer);
}else{
timer–;
$(“#btn1 span”).text(timer);
}

},1000);

//2.点击后10S内不可点击
$(“#btn2”).click(function(){
$(“#btn2”).attr(“disabled”,true);
$(“#btn2”).html(“<span>10</span>s后可再次提交”);
setInterval(function(){
timer2=$(“#btn2 span”).text();
if(timer2 == 0){
$(“#btn2”).attr(“disabled”,false);
$(“#btn2”).text(“点击提交”);
clearInterval(timer2);
}else{
timer2–;
$(“#btn2 span”).text(timer2);
}
},1000);
})

});
</script>
<style>
button{ width:200px; height:30px; text-align:center;}
</style>
</head>

<body>
<button id=”btn1″></button><br />
<button id=”btn2″>点击提交</button>
</body>
</html>

Top