inotgo.com


Tool version compatibility problem
DOM yes Document Object Model( Document object model ) Abbreviation for .

DOM It's a html It is an idea to operate all kinds of data as objects .

Like a hyperlink , As a DOM Object , You can hide it , Modify its href Address to .
Correct


DOM Put all the html All converted to nodes
Entire document Is a node
Element Is node
Element attribute Is node
Element content Is node
notes It is also a node
As in this example
Through document.getElementById Got id=d1 of div label Corresponding Element node
Then pass attributes The corresponding of the node is obtained Attribute node
Then pass childNodes Got Content node
Operation effect
 Node concept
<html> <body> <div id="d1">hello HTML DOM</div> </body> <script> function p(s){ document.write(s); document.write("<br>"); } var div1 = document.getElementById("d1"); p(" Document node "+document); p(" Element "+div1); p(" Attribute node "+div1.attributes[0]); p(" Content node "+div1.childNodes[0]); </script> </html>
<html>
<body>
<div id="d1">hello HTML DOM</div>
 
</body>
 
<script>
function p(s){
    document.write(s);
    document.write("<br>");
}
var  div1 = document.getElementById("d1");
p(" Document node "+document);
p(" Element "+div1);
p(" Attribute node "+div1.attributes[0]);
p(" Content node "+div1.childNodes[0]);
</script>
 
</html>


Source code
1. Double click the selected word 2. Triple Click to select the entire row 3. CTRL+F Find 4. F8 Full screen editing , Click restore again
Rendering Rendering complete
effect


The official account of programming , Follow and get the latest tutorials and promotions in real time , thank you .


Q & A area    
2019-09-02 attributes[0] and childnode[0]
SummerHH

Why? attributes[0] and childnode[0] Is an array




2 One answer

Liu Yiyi
Answer time :2019-09-18
There is more than one attribute and child node ~Id But it's the only one

13500 Jin
Answer time :2019-09-08
3213
3213



The answer has been submitted successfully , Auditing . Please My answer Check the answer record at , thank you
answer Or code please Fill in at least one , If you have a problem , Please ask again , Otherwise, the webmaster may not see








Please... Before asking questions land
The question has been submitted successfully , Auditing . Please My question Check the question record at , thank you
about Front end part -HTML DOM- Node concept Your questions

Try to provide Screenshot code and Abnormal information , Help to analyze and solve problems . You can also enter this station QQ Group communication : 496725845
Ask questions and try to provide complete code , Environment description , The more conducive to the recurrence of the problem , The faster your question can be answered .
Have questions about the code in the tutorial , Please provide which step , Which line is in doubt , This makes it easy to quickly locate the problem , Improve the speed at which questions are answered
In the thousands of questions that already exist , A considerable proportion , Because of the use of and webmaster Different versions of the development environment Resulting in , For example jdk, eclpise, idea, mysql,tomcat Wait, the version of the software is inconsistent .
Please use the same version as the webmaster , You can save yourself a lot of learning time . The webmaster sorted out the software versions used in teaching , It's all here , Convenient for everyone to download : /k/helloworld/helloworld-version/1718.html

Upload screenshot