Home > Web Front-end > JS Tutorial > body text

Example introduction to how to obtain the document node object_javascript skills

WBOY
Release: 2016-05-16 17:07:31
Original
1206 people have browsed it
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



Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template