elink12,
или так
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</head>
<body>
<script>
(function($) {
var pluginName = 'Plugin',
defaults = {
propertyName: "value"
},
options = {};
function Plugin( element, options ) {
this.element = element;
this.options = $.extend( {}, defaults, options) ;
this._defaults = defaults;
this._name = pluginName;
this.init();
}
Plugin.prototype = {
init: function (e) {
console.log(this.options);
$(this.element).on({"click" : this.click},"input",this.options);
},
click : function(e){
this.value = e.data.color
}
};
$.fn.Plugin = function ( options,event ) {
return this.each(function () {
plugin = new Plugin( this, options );
});
}
})(jQuery);
$( document ).ready(function() {
$('#alert').Plugin({color:'green'});
$('#alert1').Plugin({color:'red'});
});
</script>
<div id='alert'>alert<input type="text"></input></div>
<div id='alert1'>alert<input type="text"></input></div>
</body>
</html>