Home  >  Article  >  Web Front-end  >  Example introduction to how to obtain the document node object_javascript skills

Example introduction to how to obtain the document node object_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:07:311204browse
Copy code The code is as follows:



< ;title>
<script> <br><br>/* <br>How to obtain the document node object: <br><br>*/ <br>//First method, Get by id<br>function documentDemo(){ <br>var tableNode = document.getElementById("tab_id"); <br>tableNode.style.border = "5px solid #00ff00"; <br>} <br>/ /Second, through the name attribute <br>function documentDemo2(){ <br>var inputNode = document.getElementsByName("txt"); <br>alert(inputNode.length); <br>alert(inputNode[0] .value); <br><br>} <br>//The third method, through the tag name <br>function documentDemo3(){ <br>var tdNode = document.getElementsByTagName("td"); <br>alert (tdNode.length); <br>for(var x = 0 ; x < tdNode.length;x ){ <BR>alert(tdNode[x].innerText); <BR>} <BR>} <BR> </script>









This is the content in the div














java php
.net ios


This is a span area

This is a span area Link



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn