You'll probably want to set the "global" flag and use regex notation.

var f = $('#fruits');
f.html(f.html().replace(/;/g, "<br />"));


--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Apr 10, 2009, at 5:23 PM, jc_2009 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!

Reply via email to