久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

向現(xiàn)有的 JQuery 插件添加功能

Add function to existing JQuery plugin(向現(xiàn)有的 JQuery 插件添加功能)
本文介紹了向現(xiàn)有的 JQuery 插件添加功能的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

是否可以在不修改實(shí)際插件的情況下向插件添加功能?我可以在我網(wǎng)站的 js 文件中做這樣的事情嗎?

Is it possible to add a function to a plugin without modifying the actual plugin? Can I do something like this in my site's js file?

$.fn.Watermark.Refresh = function() {
        $.Watermark.HideAll();
        $.Watermark.ShowAll();
    }

(function($){
$.fn.Watermark.Refresh = function() {
        $.Watermark.HideAll();
        $.Watermark.ShowAll();
    };
})(jQuery);

都不行,第一個(gè)說(shuō) $ 未定義,第二個(gè)說(shuō) jQuery 未定義...

neither worked, the first says $ is undefined, the second that jQuery is undefined...

想法?

解決方案:任何一種方法都可以,只需在站點(diǎn) js 文件之前包含 jquery 文件即可.

Solution: Either method works, just include the jquery file before the site js file.

推薦答案

如果你愿意,你可以添加這些函數(shù),但你必須確保你也加載了 jQuery 本身和要修改的插件.如果您遇到這些錯(cuò)誤(未定義 jQuery 或$"),那么您沒(méi)有正確地做到這一點(diǎn).

You can add those functions if you want to, but you'll have to make sure that you're also loading jQuery itself and the plugin to be modified. If you're getting those errors (that jQuery or "$" are not defined), then you have not correctly done that.

現(xiàn)在,雖然您確實(shí)可以添加這些功能,但我想知道重點(diǎn)是什么.如果我要這樣做,例如:

Now, though it's true that you can add those functions, I have to wonder what the point would be. If I were to do this, for example:

$.fn.css.myFunction = function() { return "hello world"; };

那么就可以調(diào)用它了:

var str = $.fn.css.myFunction();

但那又怎樣?這對(duì)我有什么好處?我覺(jué)得用處不大.

but so what? What good does that do me? I don't think it's very useful.

這篇關(guān)于向現(xiàn)有的 JQuery 插件添加功能的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

jQuery/JavaScript Library for avatar creation?(用于創(chuàng)建頭像的 jQuery/JavaScript 庫(kù)?)
How to do following mask input problem?(如何做以下掩碼輸入問(wèn)題?)
Issues Setting Value/Label Using DropKick Javascript(使用 DropKick Javascript 設(shè)置值/標(biāo)簽的問(wèn)題)
how to unit-test private methods in jquery plugins?(如何對(duì) jquery 插件中的私有方法進(jìn)行單元測(cè)試?)
stellar.js - configuring offsets / aligning elements for a vertical scrolling website?(stellar.js - 為垂直滾動(dòng)網(wǎng)站配置偏移量/對(duì)齊元素?)
jQuery masked input plugin. select all content when textbox receives focus(jQuery 屏蔽輸入插件.當(dāng)文本框獲得焦點(diǎn)時(shí)選擇所有內(nèi)容)
主站蜘蛛池模板: 一级毛片视频在线观看 | 亚洲欧美日韩电影 | 国产在线www | 亚洲一区二区在线 | av中文在线| 日韩三级电影在线看 | 国产69久久精品成人看动漫 | 午夜久久久 | 日韩久久成人 | 国产日韩欧美激情 | 一级黄色短片 | 男人的天堂视频网站 | 亚洲午夜精品一区二区三区他趣 | 久久久久国产一区二区三区四区 | 日本视频免费观看 | 国产精品久久久久久久久久免费看 | 91精品一区二区三区久久久久久 | 我我色综合 | 日韩在线不卡视频 | 综合色在线 | 视频在线一区二区 | 精品在线视频播放 | 亚洲综合一区二区三区 | 精品视频一区二区三区在线观看 | 亚洲电影专区 | 国产成人精品福利 | 国产精品一区在线观看 | 国产精品视频免费观看 | 成人高清网站 | 91视频在线| 欧美一级精品片在线看 | 久久国 | 国产成人精品综合 | 一区二区三区在线免费观看 | 成人一区二区三区在线观看 | 日本中文在线视频 | 在线播放日韩 | 97久久超碰| 在线一区 | 精品麻豆剧传媒av国产九九九 | 日韩精品四区 |