HTML5入门2---js获取HTML元素的值

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>javascript页面</title>
                 <script type="text/javascript">
            //alert("您好,欢迎来我们的网页");
            function getValue()
            {
                var obj = document.getElementById("name");
                //window.alert("您的名字是"+obj.value);    
                if(obj.value != "张三")                {
                    alert("对不起,你的名字不存在");
                }
                else
                {
                    alert("您的名字是"+obj.value);
                }
            }
            function getValue2()
            {
                alert("第二个方法");
            }
            window.onload = function()
            {
                //alert("您是第100个访问此网页的用户");                
            }
        </script>
    </head>
    <body>
        <form name="MyForm">
            <label>账号</label>
            <input id="name" type="text" value="" /><br/><br/>
            <label>密码</label>
            <input id="password" type="password" value="" /><br/><br/>
            <input type="button" value="提交" onclick="getValue();getValue2()"/>&nbsp;&nbsp;
            <input type="reset" value="重置" />
        </form>
        <audio controls="controls" >
              <source src="resource/音乐.mp3" type="audio/ogg">
              <source src="song.mp3" type="audio/mpeg">
            Your browser does not support the audio tag.
        </audio><br/>
        <input type="date" value="" /><br/>
        <input type="email" value="" /><br/>
        <input type="color" value="" /><br/>
        <input type="tel" value="" /><br/>
        <input type="search" value=""/><br/>
        <input type="checkbox" value="" />
        <a href="resource/ApocalypsePage_Original.html">启示录</a>
    </body>
</html>
原文地址:https://www.cnblogs.com/beautiful-code/p/5065195.html