Jquery append string from array -
i have array tags = ['str1', 'str2'];
and need implement tags ul template -
<li><span>str1</span></li> <li><span>str2</span></li>
at first have tag:
<ul id="tags"> </ul>
how can on jquery?
edited : sry i'm modified question plz check now
for generating entire list content, try::
var tags = ['str1', 'str2']; var lis = $.map(tags, function(element, index) { return $("<li />").append($("<span></span>").text(element)); }); $("#tags").append(lis);
Comments
Post a Comment