javascript - Proper way to write string concatenation -


what proper way concatenate strings in javascript? example, have this:

var addmore ='<tr>'+'<td style="text-align: center">'+currentindex+'</td>'+'<td id="small"><input style="background: white; color: black;" type="text" id="number_'+currentindex+'" value="">'+'</td><td><input style="background: white; color: black;" type="text"  id="label_'+currentindex'"></td></tr>' 

it shows error in this fiddle can't find it. have checked quotation marks , seem correct.

will many quotation marks cause confusion , errors in javascript? or must " outside of '?

a better , neater way it:

 var addmore ='<tr>'+              '<td style="text-align: center">'+currentindex+'</td>'+                                      '<td id="small"><input style="background: white; color: black;" type="text" id="number_'+currentindex+'" value=""></td>'+              '<td><input style="background: white; color: black;" type="text"  id="label_'+currentindex+'"></td>'+              '</tr>'; 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -