【发布时间】:2016-02-03 08:00:05
【问题描述】:
(function ( $ ) {
$.fn.greenify = function( options ) {
var settings = $.extend({
color: "#556b2f"
}, options );
return this.css({color: settings.color});
};
//TODO another function here
if ( action === "open") {
alert("Open!");
}
if ( action === "close" ) {
alert("lose!");
}
}( jQuery ));
`$( "div" ).greenify({color: "orange"});`//setting of options
我明白上面的代码设置了greenify插件的选项,但我也想调用显示函数。
如何在设置选项仍然可用于 greenify 的情况下实现这种用法:
`$( "div" ).greenify("open");`
和
$( "div" ).greenify(open,{color: "orange"});
【问题讨论】:
标签: jquery plugins jquery-plugins