Common JavaScript errors

Source: Internet
Author: User

Beginners JavaScript, every day is always a small problem for a long time, tonight there are several small problems.

First: Use double quotes all to create a matching error

<input type= "checkbox" onmouseover= "document.getElementById (" Test "). Style.display=" None ":"/>

The change has been reported error: unexpected Toke "}" check for half a day did not find errors, the control found that the video is using single quotation marks

<input type= "checkbox" onmouseover= "document.getElementById (' Test '). style.display=" None ":"/>

After changing to single quotation marks, the mistake finally eliminated, troubled me one night. Attached link http://www.cnblogs.com/chinabc/archive/2010/11/19/1881947.html

Second: Error adding semicolon

<div id= "test" class= "Test1" onmouseover= "Toyellow ()"; onmouseout= "tored ()";>change</div>

Write a semicolon, resulting in the code after the semicolon does not execute

Third: Write more parentheses after the function name

<script>function Toyellow () {    document.getElementById ("test"). Classname= "Test2";} function tored () {      document.getElementById ("test"). Classname= "Test1";} document.getElementById ("Test"). Onmouseover=toyellow ();d Ocument.getelementbyid ("test"). Onmouseout=tored ();< /script>   

Toyellow () and tored () after the parentheses are executed normally

IV: Checked Property modification of checkbox

 Use three buttons to select all, select, and reverse the checkbox.

<! DOCTYPE html>

  

Common JavaScript errors

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.