根据您的评论,我认为您根本不需要解除绑定:
您首先要在页面加载时加载背景,然后在单击发生时加载背景。
调整图像大小时背景会发生什么应该是另一个绑定到的单独函数$(window).resize()
......所以整个事情看起来像这样:
($(function() { ... });
意思是一样$(document).ready(function() { ... })
的,只是写起来更快:
$(function() {
// Define load BG
function loadBackground() {
/// ...
}
// Define what happens to the BG image on resize
// this doesn't have to change. It should refer
// to the generic `background-image`
$(window).resize(function() {
// ...
});
// load BG when page is ready:
loadBackground();
// load another BG if there's a click:
// This will effectively cancel the previous load bg
$('.get-image').click(function() {
loadBackground();
return false;
});
});
// I'm assuming you're somehow changing which BG image is loaded
// something like loadBackground(image)... and you could initially
// load a default image, and then, if there's a click, you could
// determine what image should be based on what was clicked.