Reputation: 51
I have attached an event using "on" later I want to verify that does the control contain this event.
Example:
//adding an event
$("#divControls").on('change',".myclass input", myfunction());
//verifying the event
if($(".myclass input"].change)
{
// logic
}
How can I do that?
Upvotes: 0
Views: 29
Reputation: 82241
You can try by iterating events bound for that element.
jQuery.each($('#divControls').data('events'), function(i, event){
jQuery.each(event, function(i, handler){
console.log( handler.toString() );
});
});
Upvotes: 0
Reputation: 74420
as it is delegated event, you just need to check for parents:
var $inputWithBoundChange = $(".myclass input").filter(function(){return $(this).closest('"#divControls"').length})
This will return all input inside .myclass element which have delegated event already bound.
Upvotes: 1
Reputation: 5437
Try this one
$(document).on('change',"#divControls .myclass input", myfunction);
Upvotes: 0