jquery - Concatenate string on a loop Javascript -


i have loop hash data.

var rec = { }; (var b = 0; b < 2;b++) {     rec['id'+b] = b</p> } 

then have javascript create template.

var template ='<table><tr>' template +='<th class="id"><b>id</b></th>' template +='</tr>' template +='<% for(var = 0; < 2; i++){ %>'  template +='<tr><td><%= id+i %></td></tr>' template +='<% } %>' template +='</table>'; 

can me how concatenate string. , how use <% %> in javascript. try copy code here. im getting error

thank you

to concatenate in javascript need use addition symbol (+).

example:

var = 'hello ', b = 'my brother';

console.log(a + b);

will result in

hello brother


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -