javascript jquery fn kill从h2元素中删除字符串
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript jquery fn kill从h2元素中删除字符串相关的知识,希望对你有一定的参考价值。
jQuery.fn.kill = function(str, className) {
var regex = new RegExp(str, "gi");
return this.each(function() {
this.innerHTML = this.innerHTML.replace(regex, function(matched) {
return '<span class="' + className + '">' + matched + "</span>";
});
});
};
jQuery("h2").kill("Products ", "kill");
以上是关于javascript jquery fn kill从h2元素中删除字符串的主要内容,如果未能解决你的问题,请参考以下文章
理解jquery的$.extend()$.fn和$.fn.extend()
jquery.fn.extend与jquery.extend
理解jquery的$.extend()$.fn和$.fn.extend()
jquery $.fn方法
jQuery $.fn 方法扩展~
jQuery-其他