If you want to manipulate an element, first get it, here is a description of the next document node object access, interested friends do not miss
The code is as follows: <html> <head> <title></title> <script> /* Acquisition of document node objects: */ //First, get function Documentdemo () { var tablenode by ID document.getElementById ("tab_id"); TableNode.style.border = "5px solid #00ff00"; } //second, through the Name property function DocumentDemo2 () { var inputnode = document.getelementsbyname ("TXT"); alert ( inputnode.length); alert (inputnode[0].value); } //third, through tag name function DocumentDemo3 () { var tdnode = document.getElementsByTagName ("TD"); alert (tdnode.length); for (var x = 0; x < TDNODE.L ength;x++) { alert (tdnode[x].innertext); } } </script> <style type= "text /css "> .onediv{ width:200px; height:100px; border:1px solid #f00; margin-top:20px; } Table,td{ border:1px solid #00f; width:200px; Margin-top:20px; text-align:center; } </style> </head> <body > <input type= "button" value= "Document object Demo" onclick= "DocumentDemo3 ()" ><br/> <div class = "Onediv" > This is the content of the Div </div> <input type= "txt" name= "txt" > <input type = "txt" name= "txt" > <table cellspacing= "0" id= "tab_id" > <tr> <td> java</td> <td>php</td> </tr> <tr> <td>.net</td> <td>ios</td> </tr> </table> <span> This is a span area </span > <br/> <a href= "#" > This is a hyperlink </a> <body> </html>