自动重复调用函数,去除属性
2016-06-28 11:48
253 查看
<body> 年份:<input type="text" id="A" shx="2016" /><br /> <input type="button" value="提交" onclick="tj()" /><br /> 例子2: <input type="button" value="同意么?(10)" id="B" disabled="disabled" /> </body>
<script > function tj() { var a = document.getElementById("A"); var a1 = a.value; var a2 = a.getAttribute("shx"); if(a1 == a2) { alert("回答正确") } else { alert("错误回答") } } var b = document.getElementById("B"); var n = 10; function sx() { n--; if(n==0) { b.removeAttribute("disabled"); b.value="同意"; return; } else { b.value = "同意么?("+n+")"; } window.setTimeout("sx()",1000); } window.setTimeout("sx()",1000); </script>
window.setTimeout("sx()",1000); 每隔 1 秒,自动调用一次 sx() 函数 结果:
相关文章推荐
- 如何写.gitignore只包含指定的文件扩展名
- Canvas 最佳实践(性能篇)
- 三重Des对称加密在Android、Ios 和Java 平台的实现
- 设计模式读书笔记(二) Singleton(单例)模式
- $ionicConfigProvider-ionic 中默认安装后tap导航在顶部怎么j解决
- HTML form 垂直水平居中
- 遍历多个checkbox并获取值
- JS中的call()和apply()方法
- 7 rules of Effortless English System Secret (Ⅴ)
- oracle中if/else
- AngularJS 指令实践指南
- 开源Asp.Net Core小型社区系统
- sqlalchemy 优化count()……
- Spring Data Redis 让 NoSQL 快如闪电(2)
- spring中autowire的用法
- iOS原生App与H5页面交互笔记
- Canvas入门
- LightOJ 1317 Throwing Balls into the Baskets
- C#实现简单的双色球抽取中奖号码代码
- COFF文件格式