So I have a function like
function onLoadMe() {
//stuff in function
}
And a second function
function onLoadMeSecond() {
//stuff in function
}
I want to try and bind the onLoadMe() on the page load, but then unbind everything in onLoadMe() and load the second function onLoadMeSecond() for the element ?
i.e.
jQuery('#some-id').click(function() {
jQuery(this).unbind(onLoadMe());
onLoadMeSecond();
});
How can I do this as the above doesn’t work ?
Edit: See example http://jsfiddle.net/cer9R/5/
The correct syntax is
$(window).unbind('load',onLoadMe).Though in the JsFiddle example you are binding a handler on document ready, not page load. To unbind that, you could use
$(document).unbind('ready'). Of course, using the document ready event to bind a click handler which would unbind the (already finished) document ready handler makes no sense at all.