JS + DOM programming art Reading Note 2
Use of onclick
You can call return false to make it return invalid value. instance code:
<HTML> <body bgcolor = "# ffffff"> <div> <a href = "http://www.baidu.com" onclick = "A (); Return false;"> Baidu! </A> </div> </body> <SCRIPT type = "text/JavaScript"> function a () {document. body. bgcolor = "#669900" ;}</SCRIPT>
Small details about nodevalue
The text under each label is not the nodevalue of the label.
If you want to call the label text, use childnodes [0]
The instance code is as follows:
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML xmlns = "http://www.w3.org/1999/xhtml">
There are no more valuable tags or function descriptions for this record.
The main difference is that
Some small details ....
I have a few other questions. I wonder if you can answer them:
<HTML> <body bgcolor = "# ffffff"> <div> <a href = "http://www.baidu.com" onclick = "A ()"> Baidu! </A> </div> </body> <SCRIPT type = "text/JavaScript"> function a () {document. body. bgcolor = "#669900"; return false; // can onclick be invalid when added here ?} </SCRIPT>
I asked onclick in the forum yesterday.
Write down the result.
<HTML> <body bgcolor = "# ffffff"> <div> <a href = "http://www.baidu.com" onclick = "return a ()"> Baidu! </A> </div> </body> <SCRIPT type = "text/JavaScript"> function a () {document. body. bgcolor = "#669900"; return false ;}</SCRIPT>
You can use return a () to call it!