最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jQuery.sub()

jQuery.sub() 返回: jQuery

描述: 可創(chuàng)建一個(gè)新的jQuery副本,不影響原有的jQuery對(duì)像。

  • version added: 1.5jQuery.sub()

有兩個(gè)具體使用jQuery.sub()創(chuàng)建案例。首先是提供完全沒有破壞jQuery原有一切的方法,另一個(gè)用于幫助做jQuery插件封裝和基本命名空間。

請(qǐng)注意,jQuery.sub()不會(huì)做任何特殊的隔離 - 這不是它的意圖。所有關(guān)于jQuery的sub'd版本的方法將仍然指向原來的jQuery。(綁定和觸發(fā)仍將通過主jQuery的事件,數(shù)據(jù)將通過主綁定的元素的jQuery,Ajax的查詢和活動(dòng)將通過主jQuery的運(yùn)行,等等)。

請(qǐng)注意,如果你正在尋找使用這個(gè)開發(fā)插件,應(yīng)首先認(rèn)真考慮使用一些類似jQuery UI widget工廠,這兩個(gè)狀態(tài)和插件管理子方法。 使用jQuery UI widget的一些例子建立一個(gè)插件。

這種方法的具體使用情況下可以通過一些例子最好的描述。

Examples:

Example: 添加一個(gè)jQuery的方法,以便它不會(huì)受到外部分:

  (function(){
    var sub$ = jQuery.sub();

    sub$.fn.myCustomMethod = function(){
      return 'just for me';
    };

    sub$(document).ready(function() {
      sub$('body').myCustomMethod() // 'just for me'
    });
  })();
  
  typeof jQuery('body').myCustomMethod // undefined

Example: 改寫一些jQuery的方法,以提供新的功能。


(function() {
  var myjQuery = jQuery.sub();

  myjQuery.fn.remove = function() {
    // New functionality: Trigger a remove event
    this.trigger("remove");

    // Be sure to call the original jQuery remove method
    return jQuery.fn.remove.apply( this, arguments );
  };

  myjQuery(function($) {
    $(".menu").click(function() {
      $(this).find(".submenu").remove();
    });

    // A new remove event is now triggered from this copy of jQuery
    $(document).bind("remove", function(e) {
      $(e.target).parent().hide();
    });
  });
})();

// Regular jQuery doesn't trigger a remove event when removing an element
// This functionality is only contained within the modified 'myjQuery'.

Example: 創(chuàng)建一個(gè)插件,它返回插件的具體辦法。


(function() {
  // Create a new copy of jQuery using sub()
  var plugin = jQuery.sub();

  // Extend that copy with the new plugin methods
  plugin.fn.extend({
    open: function() {
      return this.show();
    },
    close: function() {
      return this.hide();
    }
  });

  // Add our plugin to the original jQuery
  jQuery.fn.myplugin = function() {
    this.addClass("plugin");

    // Make sure our plugin returns our special plugin version of jQuery
    return plugin( this );
  };
})();

$(document).ready(function() {
  // Call the plugin, open method now exists
  $('#main').myplugin().open();

  // Note: Calling just $("#main").open() won't work as open doesn't exist!
});
jQuery 1.6 API 中文版腳本之家整理、修訂 (2011年6月)
出国| 武威市| 赞皇县| 神池县| 招远市| 武城县| 天柱县| 诸暨市| 普安县| 夏河县| 安丘市| 冕宁县| 晋中市| 常州市| 岗巴县| 沽源县| 朝阳区| 原阳县| 楚雄市| 清河县| 宣化县| 藁城市| 临夏市| 永善县| 黄大仙区| 定州市| 禄劝| 郓城县| 习水县| 通许县| 五家渠市| 宕昌县| 周宁县| 东台市| 林西县| 河津市| 南川市| 山阴县| 萍乡市| 拉萨市| 台中市|