How to wrap part of the text with spans using jQuery?
dom, dom-traversal, jquery, word-wrap
Solution
This will search you whole DOM and replace each `Rox` with `<span>Rox</span>`:
$(':contains("Rox")').html(function(index, oldHTML) {
return oldHTML.replace(/(Rox)/g, '<span>$&</span>');
});
Live DEMO
Problem
Here is what I am trying to do ``` Fox<span>Rox</span> ``` before that ``` FoxRox ``` How do I wrap spans around `Rox`?