JSFiddle - React, Tailwind, and code Playground
HTML
Click here!
<div id="results"></div>
<!-- load two copies of jQuery -->
<script src="http://code.jquery.com/jquery-2.1.1.js"></script>
<script>var $A = jQuery;</script>
<script src="http://code.jquery.com/jquery-2.1.1.js"></script>
<script>var $B = jQuery;</script>
<!-- demonstrate independence of their event handlers -->
<script>
jQuery.each( { A: $A, B: $B }, function( key, $ ) {
var $win = $( window );
// add a troublesome click handler
$win.on( "click", whine );
// remove "all" click handlers
// NOTE: this does not affect the _other_ jQuery
$win.off("click");
// add a click handler that we want to keep
$win.on( "click", counter(key) );
});
var clicks = {};
function whine() {
alert(".off() failed");
}
function counter( key ) {
return function() {
clicks[ key ] = (clicks[ key ] || 0) + 1;
jQuery("#results").html(
jQuery.map( clicks, function( count, key ) {
return "jQuery " + key + ": " + count;
}
).join("<br />") );
};
}
</script>