Update 24 Aug '12: In jQuery 1.8, it is no longer possible to access the element's events using .data('events'). How can I check if scroll binding was added to window? To learn more, see our tips on writing great answers.
If your button is inside a #parent element, you can replace: $('#myButton').bind('click', onButtonClicked); $('#parent').delegate('#myButton', 'click', onButtonClicked); even if #myButton doesn't exist yet when this code is executed.
(And also in the minutes immediately after my comment. Use data( 'bound', 1 ) instead of addClass ('bound') is another approach that works. jQuery makes it straightforward to set up event-driven responses on page elements. I was having an event fire multiple times and each time the total amount of times it fired kept increasing. When multiple filtering arguments are given, all of the arguments provided must match for the event handler to be removed. Example. Thanks for contributing an answer to Stack Overflow! This event is limited to elements,