jQuery/Javascript find and replace all instances [duplicate]

Possible Duplicate:
Replace all instances of a pattern with regular expressions in Javascript / jQuery
How can I use jQuery to style /parts/ of all instances of a specific word?

Say I have the code:

<div class="replace">

Now, I want to replace all the < within the div with something else.

If I use $('#div').html().replace('<','somethingElse'); it only replaces the first instance.

How can I replace all the instances?




Use regex


If you want to replace it inside the div then try this.



Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.