独自のjqueryプラグインの作成


       jquery   Jquery         : 1、         :               2、         :         jquery       。Jquery.ajax() jquery.trim()  jquery                   。 3、     :            。   Jquery       : 、            jquery.[   ].js  。 、           jquery.fn   ,            jquery      、  this.each()     ,   this                 jquery   、                  ,            ,             “;”,                 。         jquery  ,          ,                ,        。    $ jquery       ,                 。         ,  ,                                        ,                            ,      。 “  ”         ,    jquery           ,              。    jquery            : ;(function($){ $.fn.yourName = function(options){  //    、     } var options = $.extend(defaults, options);//     this.each(function(){ //       }); }; })(jQuery);   : (1)、“;(function($){ })(jQuery);”       ,        ”$”     ”jquery”, ,   $             (2)、$.extend(defaults, options);      options          ,  options       defaults   。      : Var setting={validate:true,limit:5,name:foo}; Var options={validate:fasle,name:tom}; Var newoptions=$.extend(setting,options);      newoptions={validate:false,limit:5,name:tom}.   Jquery.extend()(   $.extend())               。     $.extend()      , jquery.fn.extend()       ,       :     jquery   ,      jquery   ,   addClass(),remove() 。                jquery.fn.extend()     。 function foo(options){   options=jquery.extend({   Name:“bar”,   Length:5,   dataType:”xml”   },options); };   options        ,             。   : ;(function($)){   $.fn.extend({    “functionname”:function(options){//        Options=$.extend({   odd:”odd”,   even:”even”   },options);   //    options.          , options.odd   //some codes   $(“.table”).addClass(“”);//              }   //         //      this.cleartb = function() {//         ,  cleartb            $('#emed_tb01').remove();//        }   }); }             : $(“#id_”).cleartb();//  id “id_”           cleartb   。                  :              , ;(function($){ $.fn.manhuaTip = function(options) {//    manhuaTip var defaults = {//    Event : "click", timeOut : 2000 }; var options = $.extend(defaults,options);//      var $tip = $(this);//     jquery           $tip.live(options.Event,function(e){ var type = $(this).attr('ty'); var msg = $(this).attr('msg'); var tipHtml = ''; if (type =='loading'){ tipHtml = '<img alt="" src="../images/loading.gif">'+(msg ? msg : '        ,   ...'); } else if (type =='notice'){ tipHtml = '<span class="gtl_ico_hits"></span>'+msg } else if (type =='error'){ tipHtml = '<span class="gtl_ico_fail"></span>'+msg } else if (type =='succ'){ tipHtml = '<span class="gtl_ico_succ"></span>'+msg } if ($('.msgbox_layer_wrap')) { $('.msgbox_layer_wrap').remove(); } if (st){ clearTimeout(st); } $("body").prepend("<div class='msgbox_layer_wrap'><span id='mode_tips_v2' style='z-index: 10000;' class='msgbox_layer'><span class='gtl_ico_clear'></span>"+tipHtml+"<span class='gtl_end'></span></span></div>"); $(".msgbox_layer_wrap").show(); var st = setTimeout(function (){ $(".msgbox_layer_wrap").hide(); clearTimeout(st); },options.timeOut); }); } })(jQuery)