<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <div id="one"> 今天下雨 </div> <table border="1" cellspacing="0" cellpadding="0"> <!--<tr><th>Header</th></tr> <tr><td>Data</td></tr>--> </table> <input type="text" name="two" id="two" value="269" /> <ul> <li></li> <li></li> <li></li> <li></li> </ul> </body> </html> <script type="text/javascript"> var tab = document.getElementsByTagName("table") var str = ""; for(var i = 0;i<4;i++){ str = str + "<tr>" for(var j = 0;j<4;j++){ str = str + "<td>嘿嘿</td>" } str = str + "</tr>" } tab[0].innerHTML = str var inpt = document.getElementById("two"); alert(inpt.value); var three = document.getElementsByTagName("li"); console.log(three[0]); var one = document.getElementById("one"); </script>