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 -

c# - Retrieve google contact -

javascript - How to insert selected radio button value into table cell -