The application _javascript Techniques of "+ +" in JavaScript

Source: Internet
Author: User
Addition Assignment operator (+ =). Adds a variable value to an expression value, and assigns it to the variable.
In writing javascrpt often use, to tell the truth I did not quite understand before. Read a lot of code feeling is because a variable is too long to use it to separate lines to write it. But it's and solves my other problems.
At some point we need to use a series of HTML code as a variable, and there are always quotes in the HTML. Like what
Copy Code code as follows:

var nameform= ' <div id= "pointname" ><input id= "Pointnametext" type= "text" size=18 value= "Enter your landmark name" class= "here Inputfield "onfocus=" This.value=null "onblur=" this.value= ' Please enter the landmark name '/></div> ' here;

At this point you will find that the question of quotes always bothers you. This time with ' + = ' to solve the problem.
Copy Code code as follows:

var nameform= ' <div id= ' Pointname "><input id=" Pointnametext " type=" text " size=18 value=" Please enter the landmark name " class=" Inputfield " onfocus=" here This.value=null " onblur=" this.value= ';   
nameform+= ' ";  
Nameform+= ' Please enter the landmark name ';  
nameform+= ' ';  
nameform+= '/></div> '; 

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.