为了账号安全,请及时绑定邮箱和手机立即绑定

为什么点击H1无法弹出提示框呢?

为什么点击H1无法弹出提示框呢?

慕标8997690 2016-06-29 23:22:22
<!DOCTYPE HTML><html>  <head>  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />  <title>JavaScript</title>  </head>  <body>              <form name="Input">            <table align="center" width="500px" height="50%" border="1">                <tr>                    <td align="center" width="100px">                        学号:                    </td>                    <td align="center" width="300px">                        <input type="text" id=userid name="user" onblur="validate();">                        <div id=usermsg></div>                    </td>                </tr>                <tr>                    <td align="center" width="100px">                        姓名:                    </td>                        <td align="center">                        <input type="text" name="name">                    </td>                </tr>                <tr>                    <td align="center" width="%45">                        性别:                    </td>                    <td align="center">                        <input type="radio" name="sex" value="男">                        男                        <input type="radio" name="sex" value="女">                        女                    </td>                </tr>                <tr>                    <td align="center" width="30%">                        年龄:                    </td>                    <td align="center" width="300px">                        <input type="text" name="age">                    </td>                </tr>                <tr>                    <td align="center" width="100px">                        地址:                    </td>                    <td align="center" width="300px">                        <input type="text" name="addr">                    </td>                </tr>            </table>        </form>        <h1 id="myHead" onclick="getValue()">            看看三种获取节点的方法?        </h1>        <p>            点击标题弹出它的值。        </p>        <input type="button" onclick="getElements()"            value="看看name为sex的节点有几个?" />        <Br>        <input type="button" onclick="getTagElements()"            value="看看标签名为input的节点有几个?" />                 <script type="text/javascript">         function getValue()          {            var myH=document.getELementById("myHead");                alert(myH.innerHTML);          }          function getElements()          {            var myS=document.getElementsByName("sex");              alert(myS.length);          }          function getTagElements()          {            var myI=document.getElementsByTagName("input");                alert(myI.length);          }              </script>            </body></html>
查看完整描述

1 回答

已采纳
?
super_mb

TA贡献101条经验 获得超107个赞

var myH=document.getELementById("myHead");

函数getValue()中,这一句的getELementById写错了,getElementById才对吧,Element的l是小写的。改过来就好了

查看完整回答
1 反对 回复 2016-06-29
  • 1 回答
  • 0 关注
  • 1069 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信