JS + DOM programming art Reading Note 2

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.