"+ =" In JavaScript

Source: Internet
Author: User

Addition value assignment operator (+ = ). Add the variable value and expression value and assign it to the variable.
It is often used when writing JavaScrpt. To be honest, I didn't quite understand it before. After reading a lot of code, it seems that a variable is too long to be written in several lines. But it solves my other problems.
In some cases, we need to use a series of HTML code as variables, while HTML always contains some quotation marks. For example
Copy codeThe Code is as follows:
Var Nameform = '<div id = "PointName"> <input id = "PointNameText" type = "text" size = 18 value = "Enter the landmark name" class = "inputField "onFocus =" this. value = null "onBlur =" this. value = 'Enter the landmark name' "/> </div> ';

At this time, you will find that the quotation marks are always bothering you. At this time, use '+ =' to solve the problem.
Copy codeThe Code is as follows:
Var Nameform = '<div id = "PointName"> <input id = "PointNameText" type = "text" size = 18 value = "Enter the landmark name" class = "inputField "onFocus =" this. value = null "onBlur =" this. value = ';
Nameform + = "'";
Nameform + = 'Enter the landmark name' here ';
Nameform + = "'";
Nameform + = '"/> </div> ';

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.