ABooooo
9/1/2016 - 6:27 AM

jQuery find text and replace with custom text

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));