jQuery為開發插件提拱了兩個方法,分別是: 
JavaScript代碼 
復制代碼 代碼如下:
 
jQuery.fn.extend(object); 
jQuery.extend(object); 
復制代碼 代碼如下:
 
jQuery.fn = jQuery.prototype = { 
   init: function( selector, context ) {//….  
   //…… 
}; 
復制代碼 代碼如下:
 
$.extend({ 
  add:function(a,b){return a+b;} 
}); 
復制代碼 代碼如下:
 
$.add(3,4); //return 7 
復制代碼 代碼如下:
 
$.fn.extend({ 
alertWhileClick:function(){ 
$(this).click(function(){ 
alert($(this).val()); 
}); 
} 
}); 
$(“#input1″).alertWhileClick(); //頁面上為:<input id=”input1″ type=”text”/> 
新聞熱點
疑難解答
圖片精選