I’ve a page load some contents by Ajax, and also bind events via .on() method to the new comming elements.
Is there anyway to get all the binding events on <div class="inner">?
I’ve try $("div.inner").data('events') in the console after all contents loaded,
but there is nothing but undefined.
Html:
<div id="out"><p></p></div>
JavaScript: (not really ajax, just a simulation)
var innDiv = '<div class="inner">inner</div>' +
'<div class="inner">inner</div>' +
'<div class="inner">inner</div>';
$(document).on('click','.inner', function(){$(this).toggleClass("green")});
setTimeout('$("#out").append(innDiv)',2000);
Here is the jsfiddle Code demo.
Since you bound your events to
documentelement, try this: