从原型迁移到 jquery [英] Migrating from prototype to jquery

查看:25
本文介绍了从原型迁移到 jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的 js 库从原型迁移到 jquery.但是,我不知道如何替换以下代码:

I am migrating my js lib from prototype to jquery. However, I don't know how to replace the following code:

var utilityMethods = {     
        autoHide : function(element) {
               //...
}

Element.addMethods('SPAN', utilityMethods);

是否有扩展 DOM 的 jQuery 等价物?

Is there a jQuery equivalent for extending the DOM?

谢谢

推荐答案

你像这样扩展 JQuery 对象:

You extend JQuery objects like so:

var utilityMethods = {     
    autoHide : function(element) {
           //...
    }
};

jQuery.fn.extend(utilityMethods);

更多信息:http://docs.jquery.com/Core/jQuery.extend

这篇关于从原型迁移到 jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆