Created
September 1, 2016 06:27
-
-
Save ABooooo/75bb989c73796615963b8b0621677ad5 to your computer and use it in GitHub Desktop.
jQuery find text and replace with custom text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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