javascript replace commas with spaces from json array

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-06-15T02:21:44Z Indexed on 2010/06/15 2:22 UTC
Read the original article Hit count: 190

Filed under:
|
|

I have a looping function creating:

<li id="id1" name="Tag1,Tag2,Tag3">
<li id="id2" name="Tag1,Tag2,Tag3">


$.each(data.posts, function(i, post){       
 $('<li >', {id: this.id , name: post.tags})  
});

How do I replace the commas between the tags with spaces. Also is there a way I can send the tags to a "class" attribute instead of "name". It seems to not work in Safari.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery