zoukankan      html  css  js  c++  java
  • DOM 练习

    练习一:

    <!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=utf-8" />
    <title>无标题文档</title>
    </head>
    
    <body>
    <!--中华人民共和国成立于哪一年?-->
    <form>
    中华人民共和国成立于哪一年:<input type="text" daan="1949年" id="f"/>
    <input type="button" onclick="nian()" value="检查答案"/>
    </form>
    </body>
    </html>
    <script>
    function nian()
    {
        var a=document.getElementById("f");
        var a1=a.value;
        var a2=a.getAttribute("daan");
        if(a1==a2)
        {
            alert("答案正确!");
        }
        else
        {
            alert("答案错误!");
        }
    }
    </script>

    练习二:

    <!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=utf-8" />
    <title>无标题文档</title>
    </head>
    
    <body>
    <!--同意按钮,倒计时10秒,同意按钮变成可提交的-->
    <form>
    <input type="submit" id="f" value="同意(9)" disabled="disabled"/>
    </form>
    </body>
    </html>
    <script>
    var n=10;
    var a=document.getElementById("f");
    function dao()
    {
        n--;
        if(n==0)
        {
            a.removeAttribute("disabled");
            a.value="同意";
        }
        else
        {
            a.value="同意("+n+""
            window.setTimeout("dao()",1000);
        }
    }
    window.setTimeout("dao()",1000);/*这一步是调用“dao()”这个函数里面的内容,一进来首先走这一步,经过这一步调用,函数里面的内容才能使用*/
    </script>
  • 相关阅读:
    python深度学习之灾难求生预测(titanic)
    python深度学习之语音识别(speech recognize)
    greenplum集群状态恢复与同步
    python手写图片识别MNIST
    python随机森林房价预测
    机器学习常用模型
    python爬虫优化和错误日志分析
    数据挖掘数学基础
    虚拟机spark集群搭建
    虚拟机zookeeper和hbase集群搭建
  • 原文地址:https://www.cnblogs.com/zyg316/p/5528757.html
Copyright © 2011-2022 走看看