Reputation: 3920
using java script i need to add dynamic values to a text contained in the html.
In the following code i nee to print the Screenshot based on the count 0,1,2 like
that
var html="";
for(var i=0; i<count;i++){
html += ' <a target="_blank" href="/test.html">Screenshot</a><br>';
}
errEl.html(html);
eg: Screenshot_0
Screenshot_1
Screenshot_2
how can made changes in the code html += ' <a target="_blank" href="/test.html">Screenshot</a><br>';
Upvotes: 0
Views: 31
Reputation: 780949
The text is just a string, so you can perform string concatenation with +
:
for(var i=0; i<count;i++){
html += ' <a target="_blank" href="/test.html">Screenshot ' + i + '</a><br>';
}
Upvotes: 2