あなたのコメントに基づいて、バインドを解除する必要はまったくないと思います:
ページが読み込まれるときに最初に背景を読み込み、次にクリックが発生したときに背景を読み込みます。
画像のサイズが変更されたときに背景に何が起こるかは、別の別の関数にバインドする必要がある$(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.