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); 

see: http://jsfiddle.net/syqpa/1/


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -