close
<div>
<p>
哥林多前書13:4-5哥林多前書13:4-5哥林多前書13:4-5哥林多前書13:4-5哥林多前書13:4-5哥林多前書13:4-5哥林多前書13:4-5哥林多前書13:4-5哥林多前書13:4-5哥林多前書13:4-5
</p>
<div>
.someclass {
color: red;
}
var yourstring="多";
$('p:contains('+yourstring+')', document.body).each(function(){
console.log(this);
$(this).html($(this).html().replace(
new RegExp(yourstring, 'g'), '<span class="someclass">'+yourstring+'</span>'
));
});
http://stackoverflow.com/questions/13780784/jquery-find-and-change-style-of-a-string
全站熱搜