网站大量收购独家精品文档,联系QQ:2885784924

用jquery写插件(Write a plug-in with jquery).doc

  1. 1、本文档共12页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
用jquery写插件(Write a plug-in with jquery)

用jquery写插件(Write a plug-in with jquery) 1, plug-in class level 1.1 add a new global function (jQuery.foo = function) { Alert (This is a test.Just do you test01); } 1.2 increase the number of global functions (jQuery.foo = function) { Alert (This is a test. This is only a test.); }; JQuery.bar = function (param) { Alert (This function takes a parameter, which is + param + .); }; JQuery.alertParm (param) { Alert (This function takes a parameter, which is +param+); } The call and a function of the same: (jQuery.foo); jQuery.bar ($.foo); or ($.bar); (bar); 1.3 using jQuery.extend (object); JQuery.extent ({ {(foo:function) Alert (This is a test----use jQuery.extend (Object) ); } Bar:function (param) { Alert (This function takes a parameter, which is +param+); } }); 1.4 use namespace Although in the jQuery namespace, we prohibit the use of a large number of javaScript function and variable names. But still can not avoid Free some function or variable name in other conflicts jQuery plug-in, so we used some methods package to another custom namespace. JQuery.myPlugin = { {(foo:function) Alert (This is a test function ); } Bar:function (param) { Alert (This funciotn takes a param, which is +param+); } }; The namespace function is still the global functions, the method call is used: ($.myPlugin.foo); $.myPlugin.bar (param); 2, the object level plug-in development The plug-in development object level need two forms as follows: Form 1: (function ($) { $.fn.extend ({ PluginName:function (OPT, callback) { //our plugin implemention code goes here } }) }) (jQuery) Form 2: (function ($) { ($.fn.pluginName = function) { //our plugin implemention code goes here }; }); 2.1 in the JQuery namespace to declare a name ($.fn.hilight = function) { Plugin implementation code goes here. / / Our }; Our plugin is invoked by this: $(#myDiv).Hilight (); The 2.2 options parameters to control the behavior of the plug-in Lets add function specifies the foreground and background colors for our plugin.

文档评论(0)

jgx3536 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:6111134150000003

1亿VIP精品文档

相关文档