在我的自定义插件中添加此 $(document).click 事件的正确位置在哪里?
(function ( $ ) {
$.fn.greenify = function( options ) {
$(document).click(function (event) { // where do I add this?
alert('this id was clicked');
});
// 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 ));
$('#a,#b,#c').greenify({
// My settings goes here
});