0

任何人都知道如何将默认值传递给元素。这是在 Jquery 样板中。例如,propertyname 现在应该是“这是一个测试”。TIA

;(function ( $, window, undefined ) {

var pluginName = 'defaultPluginName',
    document = window.document,
    defaults = {
        propertyName: "value"
    };

function Plugin( element, options ) {
    this.element = element;
    this.options = $.extend( {}, defaults, options) ;
     _option = option;
    this._defaults = defaults;
    this._name = pluginName;

    this.init();


}

Plugin.prototype.init = function () {
     $("#test").text(_option.propertyName);
    // code goes here   


};//init

$.fn[pluginName] = function ( options ) {
    return this.each(function () {
        if (!$.data(this, 'plugin_' + pluginName)) {
            $.data(this, 'plugin_' + pluginName, new Plugin( this, options ));
        }
    });
  };

}(jQuery, window));


$('#test').defaultPluginName({propertyName: "this is a test"});
4

0 回答 0