- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- <html>
- <head>
- <title>测试</title>
- </head>
- <script language="javascript">
- var t = null;
- var flag = true;
- function check(obj) {
- if (flag) {
- obj.disabled = flag;
- flag = false;
- t = setTimeout(function(){disable(obj)}, 5000); // 5秒间隔
- window.open("http://www.baidu.com", "newWindow");
- }
- }
- function disable(obj) {
- obj.disabled = flag;
- flag = true;
- if (t != null)
- clearTimeout(t);
- }
- </script>
- <body>
- <a href="#" onclick="check(this)">ceshi1</a>
- </body>
- </html>
9秒后按钮激活代码
- <input class="button" type="submit" name="rulesubmit" value="同 意" style="height: 23px">
- <input class="button" type="button" name="return" value="不同意" style="height: 23px" onclick="javascript:history.go(-1);">
- </center>
- </form>
- <script type="text/javascript">
- var secs = 9;
- var wait = secs * 1000;
- document.bbrules.rulesubmit.value = "同 意(" + secs + ")";
- document.bbrules.rulesubmit.disabled = true;
- for(i = 1; i <= secs; i++) {
- window.setTimeout("update(" + i + ")", i * 1000);
- }
- window.setTimeout("timer()", wait);
- function update(num, value) {
- if(num == (wait/1000)) {
- document.bbrules.rulesubmit.value = "同 意";
- } else {
- printnr = (wait / 1000) - num;
- document.bbrules.rulesubmit.value = "同 意(" + printnr + ")";
- }
- }
- function timer() {
- document.bbrules.rulesubmit.disabled = false;
- document.bbrules.rulesubmit.value = "同 意";
- }
- </script>
jQuery one当使用 one() 方法时,每个元素只能运行一次事件处理器函数
- $("p").one("click",function(){
- });