icemanpro
V2EX  ›  jQuery

插件已初始化了,能不能再次修改该插件某值?

  •  
  •   icemanpro · Mar 11, 2016 · 2777 views
    This topic created in 3774 days ago, the information mentioned may be changed or developed.
    插件类似
    (function ( $ ) {
    $.fn.greenify = function( options ) {

    // This is the easiest way to have default options.
    var settings = $.extend({
    // These are the defaults.
    color: "#556b2f",
    backgroundColor: "white"
    }, options );

    // Greenify the collection based on the settings variable.
    return this.css({
    color: settings.color,
    backgroundColor: settings.backgroundColor
    });

    };

    }( jQuery ));

    /* Example usage */
    $( "div" ).greenify({
    color: "orange"
    });

    在已初始化后,如何再修改“ backgroundColor ”的值?
    1 replies    2016-03-11 12:21:24 +08:00
    jwk345
        1
    jwk345  
       Mar 11, 2016 via iPhone
    $("div").greenify("bacgroundColor","#aaaaaa");
    这样吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2836 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 14:45 · PVG 22:45 · LAX 07:45 · JFK 10:45
    ♥ Do have faith in what you're doing.