V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
icemanpro
V2EX  ›  jQuery

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

  •  
  •   icemanpro · 2016-03-11 12:03:32 +08:00 · 2063 次点击
    这是一个创建于 2967 天前的主题,其中的信息可能已经有所发展或是发生改变。
    插件类似
    (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 条回复    2016-03-11 12:21:24 +08:00
    jamesxu
        1
    jamesxu  
       2016-03-11 12:21:24 +08:00 via iPhone
    $("div").greenify("bacgroundColor","#aaaaaa");
    这样吧
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3259 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 13:09 · PVG 21:09 · LAX 06:09 · JFK 09:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.