JSFiddle - React, Tailwind, and code Playground
by Brunno Romero
HTML
<input id="comUnbind" type="button" value="com unbind">
<input id="semUnbind" type="button" value="sem unbind">
JavaScript
(function ($) {
jQuery.fn.algumaCoisaComUnbind = function () {
//ele remove todos os eventos antes de setar
$(this).unbind('click');
//seta seu evento
$(this).on('click', function () {
alert("teste1");
});
}
jQuery.fn.algumaCoisaSemUnbind = function () {
//seta seu evento
$(this).on('click', function () {
alert("teste1");
});
}
//com
$('#comUnbind').algumaCoisaComUnbind();
$('#comUnbind').algumaCoisaComUnbind();
$('#comUnbind').algumaCoisaComUnbind();
//sem
$('#semUnbind').algumaCoisaSemUnbind();
$('#semUnbind').algumaCoisaSemUnbind();
$('#semUnbind').algumaCoisaSemUnbind();
})(jQuery);