JavaScript Primer Classic (fifth edition)-Tsinghua Press's "classic" error

Source: Internet
Author: User

The school textbooks are so rotten that they buy their own books.

It was the beginning of the classic, the opening of the Startled me ~

Nineth page ≯1.4/ch1_example2.html/

1 <Script>2     //Script block 23 document bgcolor="Red";4 Alert ("Second script block");5 </Script>


Run without passing, carefully examine the found

1 document BgColor should be Document.bgcolor

If you say ". "Written" is a clerical error, then "bgcolor" in JavaScript is a beginner's mistake.

HTML is not sensitive to capitalization, and it is unforgivable that code in <script> does not pay attention to capitalization .

JavaScript is sensitive to case-insensitive! JavaScript is sensitive to case-insensitive! JavaScript is sensitive to case-insensitive!

Then you should change the

1 document.bgColor= "Red" 2 3 or use CSS styles: 4 document.body.style.backgroundColor= "Red"

if both are used, first use the JavaScript style, and then CSS style, otherwise the following JS style is invalid. namely:

1 <Script>2 Document.bgcolor="Red"; //JS Style3 Alert ("Second script block");4 </Script>5     6 <Script>7 Document.body.style.backgroundColor="Blue";//CSS Styles8 Alert ("Third script block");9 </Script>

Specific reasons I do not know, just novice.

JavaScript Primer Classic (fifth edition)-Tsinghua Press's "classic" error

Related Article

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.