I have a function which will resize the image background when the page is loaded,
$(document).ready(function(){
loadBackground();
});
and I want to ‘unload’ or ‘remove’ this loaded function when I click on a button so that I can load this function anew instead of loading it on top of the page,
$('.get-image').click(function(){
$(window).unbind("resize",loadBackground);
loadBackground();
return false;
});
but I can’t make it work! any ideas please?
thanks,
Lau
Based on your comments, I don’t think you need to unbind at all:
You first want to load the background when the page is loaded, and then you want to load the background when a click happens.
What happens to the background when the image is resized should be another separate function that is bound to
$(window).resize()… so the whole thing will look like this:(
$(function() { ... });means the same as$(document).ready(function() { ... })it’s just faster to write: