JSFiddle - React, Tailwind, and code Playground
HTML
<a id="foo">test</a>
JavaScript
// Initialization
$('#foo').click(function(){alert('Hi');});
// Store event handler
click_handles = [];
$.each( $._data($('#foo').get(0), "events")['click'], function(i,handle){
// alert(handle.handler);
click_handles.push(handle.handler);
});
// Remove handles
$('#foo').off('click');
$('#foo').click(); // Example that nothing will happen
// Do your stuff here
// Restore event handler
length = click_handles.length;
for(var i=0; i<length; i++) {
$('#foo').click( click_handles[i]);
}
$('#foo').click(); // Example that something will happen