Over the years, javascript has become very popular, mainly due to the spread of AJAX applications, the development of Web2.0… As a result, many javascript frameworks have emerged. I chose jQuery mainly because of its idea of “write less,do more”, because I am a picky person, and I will look up the code I have written from time to time to see if there is anything I can simplify and optimize. One is to promote continuous learning, and the other is to apply new ideas and technologies to it.

JQuery plugins have been written before, and there are many examples on the web. Here briefly for some writing, mainly the description of shorthand, see the following code:

<script type="text/javascript" SRC ="jquery-1.4.2.js"></script> <script type="text/javascript"> (function($) {//PI_TestPlugIn is the name of the plugin, which is also the operation object of the plugin. $.fn.PI_TestPlugIn= {Info:{Name: "TestPlugIn", Ver: "1.0.0.0", Corp: "Lzhdim", Author: "lzhdim", Date: "2010-01-01 08:00:00", Copyright: "Copyright @ 2000-2010 Lzhdim Technology Software All Rights Reserved", License: "GPL"}, / / function with the object parameters, this parameter is an object that has the attribute FunctionWithParams: function (paramObj) {/ / using parameter, whether to use the default value of var params = paramObj? ParamObj: {param1: "1", param2: "2"}; return this.Info.Name + ".FunctionWithParamObject"; }, / / function with parameter, this parameter is a variable FunctionWithParam: function (varparam) {/ / using parameter, whether to use the default value of var param = varparam? varparam : null; return this.Info.Name + ".FunctionWithParam"; }, / / no FunctionWithOutParam with parameter of the function: the function () {return this. Info. Name + ". FunctionWithOutParam "; }}; })(jQuery); //jQuery extends the API function; //jQuery extends the API function; (function($) {$.extend({//FN_TestExtendFunction); Here I use the abbreviation FN_ to define the function object prefix FN_TestExtendFunction: {// basic information about the extension function Info:{Name: "TestExtendFunction", Ver: "1.0.0.0", Corp: "Lzhdim", Author: "Lzhdim", Date: "2010-01-01 08:00:00", Copyright: "Copyright @ 2000-2010 Lzhdim Technology Software All Rights Reserved", License: "GPL"}, / / function with the object parameters, this parameter is an object that has the attribute FunctionWithParams: function (paramObj) {/ / using parameter, whether to use the default value of var params = paramObj? paramObj : { param1: "1", param2: "2" }; return this.Info.Name + ".FunctionWithParamObect"; }, FunctionWithParam: function (varparam) {varparam = varparam? varparam : null; return this.FunctionWithOutParam() + ".FunctionWithParam"; }, / / don't have the function object parameter FunctionWithOutParam: function () {return this. Info. Name + ". FunctionWithOutParam "; }}}); })(jQuery); $(function () {var params = {param1: "3", param2: "4"}; alert(params.param1); alert($(this).PI_TestPlugIn.FunctionWithParams(params)); alert($.FN_TestExtendFunction.FunctionWithParam(params)); }); </script>Copy the code