开发者

jQuery: how to override default methods (i.e html, append) for particular element?

So for example I what that after automaticaly execute come code after I call el.html("...") how do I override the cored method for specific element?

I found that http://www.bennadel.com/blog/1624-Ask-Ben-Overriding-Core-jQuery-Methods.htm but I can not get how override core method only for开发者_高级运维 a particular element.


Why not just filter the current object and loop through the items you want? Something like this should work:

(function(){
    var original = jQuery.fn.append;

    jQuery.fn.append = function(){
        this.filter("yourselector").each(function(){
            // Do stuff
        });

        return original.apply(this, arguments);
    }
})();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜