Is it possible to check if a jQuery object supports firing an event handler for a specific event? I have a function that takes a DOM element and I want to listen for “load” to fade in the element using the following:
element.css({ opacity: 0.0 });
element.bind('load', function() { $(this).animate({ opacity: 1.0 }); });
Unfortunately, this fails if the passed in element is not an image (as it will always be transparent). Thanks!
jQuery can bind the
'load'event to any DOM element (<==This never fails). However, that event does not fire at any DOM element (It fires atwindow,document, scripts, stylesheets, images, iframes, etc.).If the
'load'event does not fire at a given element (for instance, a DIV), then there is no point in binding a load handler to that element.