Skip to content

Instantly share code, notes, and snippets.

@ABooooo
Created September 1, 2016 06:27
Show Gist options
  • Save ABooooo/75bb989c73796615963b8b0621677ad5 to your computer and use it in GitHub Desktop.
Save ABooooo/75bb989c73796615963b8b0621677ad5 to your computer and use it in GitHub Desktop.
jQuery find text and replace with custom text
(function($){
$(document).ready(function(){
$("div").each(function () {
// var this is the current element's DOM object
if (this.innerHTML.indexOf("CōV") != -1) {
//$(this).addClass('cov');
$(this).html(
$(this).html().replace(/(\")?(CōV)(?!\")/gi, function ($0, $1) {
return $1 ? $0 : '<span class="cov">CōV</span>';
})
);
}
});
});
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment