這樣寫出來后,input那個彈出來的數值是 8,我怎么數也沒有8個input, 是怎么回事?
<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>
2018-12-17
8個沒毛病,你數錯了兄弟
2018-11-03
這樣你應該很清楚了
2018-10-25
網頁表格上有6個,按鈕也算input,按鈕有2個,所以確實是8個input