I know I can attach an custom event like this
$("#customDropdownBox").on("clickOutside", function(){
$(this).hide(300, hideCallback);
})
I know I can attach a click event on the body to find every elements which has the custom event attached to them like this
$("body").on("click", function(event){
$.each($("body *"), function(i, o){
if($._data(o, "events") && $._data(o, "events")["clickOutside"])
$(o).trigger("clickOutside");
})
})
I was wondering if there could be a faster way of doing this without having to loop through ALL (*) elements of the DOM. I know I can filter by using something like
$("body div.classx")
but I'd rather not hardcode a specific ID or class. I was wondering if there was a kind of selector that could acheive this. Something like
$("body *{event:'clickOutside'}")
or
$.findEvent("clickOutside");