Replace Only Replacing The First
I am using the following code to allow line breaks in the JQuery UI tooltip function. $(function() { $( document ).tooltip(); $('.linebreak').tooltip({ content:
Solution 1:
To perform a global replacement you can use g
:
Try this
callback($(this).prop('title').replace(/\|/g, '<br />'));
More infor is HERE.
Solution 2:
replace(/\|/g, '<br />')
Have a look at this previous SO answer: What does the regular expression /_/g mean?
See this fiddle: http://jsfiddle.net/U3VxQ/
Solution 3:
use regular expresion Try this
.replace(newRegExp('|', 'g'), '<br/>')
Post a Comment for "Replace Only Replacing The First"