首頁  >  核心  > jQuery.fn.extend(object)

返回值:jQuery jQuery.fn.extend(object)

概述

擴充套件 jQuery 元素集來提供新的方法(通常用來製作外掛)。

檢視這裡 plugins 可以獲取更多資訊。

參數

object Object V1.0

用來擴充 jQuery 對象。

示例

描述:

增加兩個外掛方法。

jQuery 程式碼:

jQuery.fn.extend({
  check: function() {
    return this.each(function() { this.checked = true; });
  },
  uncheck: function() {
    return this.each(function() { this.checked = false; });
  }
});
結果:

$("input[type=checkbox]").check();
$("input[type=radio]").uncheck();