JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<div id="ta">
<textarea id="textarea0">text0</textarea>
</div>
<ul id="log"></ul>
</body>
</html>
JavaScript
jQuery.fn.tarea = function(options) {
return this.each(function() {
var $textarea = $(this);
$textarea.on('blur', function (e) {
options.callback(e, $textarea.val());
});
});
};
$("#ta textarea").tarea({
callback: function(e, value) {
alert(e.target.id + ' ' + value);
}
});
for (var i = 1; i<4; i++) {
$("<textarea id='textarea"+ i +"'>text"+ i +"</textarea>").appendTo("#ta").tarea({
callback: function(e, value) {
alert(e.target.id + ' ' + value);
}
});
}