http://www.css88.com/archives/2484
这个是原作者链接
(function($){
$.fn.highLight = function(str) {
if(str == undefined || str ==" ") {
return this.find("span.highlight").each(function() {
this.parentNode.firstChild.nodeName;
with (this.parentNode) {
replaceChild(this.firstChild, this);
normalize();
}
}).end();
} else {
$(this).each(function(){
elt = $(this).get(0);
elt.normalize();
$.each($.makeArray(elt.childNodes), function(i, node){
if(node.nodeType == 3) {
var searchnode = node;
var pos = searchnode.data.indexOf(str);
if(pos >= 0) {//查找
var spannode = document.createElement('span');