How to use createElement to create a new table?
问题 Why the following code doesn't work? <html> <head> <script type="text/javascript"> function addTable() { var table = document.createElement('table'); table.innerHTML = "<tr><td>123</td><td>456</td></tr>"; document.getElementById("addtable").appendChild(table); } </script> </head> <body> <input type="submit" value="New Table" onClick="addTable()"/> <div id="addtable"></div> </body> </html> 回答1: To the best of my knowledge, setting the innerHTML property of a table element or table section