I think you would be best off with a Regular Expression: var f = $("#fruits"); f.html( f.html().replace(/;/g,"<br/>") );
"/g enables "global" matching. When using the replace() method, specify this modifier to replace all matches, rather than only the first one." http://www.regular-expressions.info/javascript.html On Apr 10, 11:23 pm, jc_2009 <joh.des...@gmail.com> wrote: > Hi, > > How to do a find and replace with Jquery. > > For example... > > Current: > <div id="fruits">Apple;Banana;Orange;Peach</div> > > I want it to look like this: > <div id="fruits">Apple<br />Banana<br />Orange<br />Peach</div> > > I found and tried this code but it only does the first one. I don't > know how to loop it. > > var f = $('#fruits'); > f.html(f.html().replace(";", "<br />")); > > Any help would be appreciated. Thanks!