开发者

JQuery change background and keep it

My jquery code looks like this:

$(document).ready(function() {
       $('.French').click(function(){ changeBackground(); 
    });
});

function changeBackground(){
    $("#title").css('backgroundPosition', '0px -120px' );
}

works beautifully only one problem : after the click the background returns to the initi开发者_如何学运维al state. How can I keep new background after the click?

Thanks for the ideas!


All working for me only thing that you can change is this:

$(document).ready(function() {
       $('.French').click(changeBackground);
});

function changeBackground(){
    $("#title").css('backgroundPosition', '0px -120px' );
}

here is working example using jQuery 1.5


Change the backgroundPosition to background-position. Also make sure you have use the latest version of JQuery (1.5).


Is the page doing a full page postback at any time? (Reloading from the server?)

If so, I believe you'll have to keep track of the state with code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜