Pop by for a character or word document

 First we have to understand what: DOM tree

Through the following code:

<!DOCTYPE html>
<html>
<body>

<p><a id="myAnchor" href="http://www.w3school.com.cn/">W3School</a></p>

<P> Click the button to display the value of the href attribute linked above. </ P>

<Button onclick = "myFunction ()"> Try </ button>

<p id="demo"></p>

<script>
function myFunction() {
var x = document.getElementById("myAnchor").href;
document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

 

The results show a button:

w3school

 

Read it? If you do not know can own try.

Guess you like

Origin www.cnblogs.com/rakinda/p/11232469.html