jQuery悬停在固定的pozition中更改背景图像(jQuery hover change background image in fixed pozition)
您好我的项目我有一个背景图片
background: url('img/1.JPG') fixed;当div (".boxy")将被悬停时,我试图使用jQuery更改此背景图像。 这是我在jQuery中设法做的
$(document).ready(function() { $(".boxy").hover( function() { $("body").css(??????); //what should i write here in order to change background image in img/2.JPG }, function() { $("body").css(??????); // what should i write here in order to chage background image in img/1.JPG } ); });Hello on my project I have a background image
background: url('img/1.JPG') fixed;I am trying to change this background image using jQuery when a div (".boxy") will be hoverd. Here is what i managed to do in jQuery
$(document).ready(function() { $(".boxy").hover( function() { $("body").css(??????); //what should i write here in order to change background image in img/2.JPG }, function() { $("body").css(??????); // what should i write here in order to chage background image in img/1.JPG } ); });最满意答案
$(document).ready(function () { $(".boxy").hover(function () { $("body").css('backgroundImage', 'url(img/2.JPG)'); }, function () { $("body").css('backgroundImage', 'url(img/1.JPG)'); }); });jsFiddle示例
$(document).ready(function () { $(".boxy").hover(function () { $("body").css('backgroundImage', 'url(img/2.JPG)'); }, function () { $("body").css('backgroundImage', 'url(img/1.JPG)'); }); });jsFiddle example
更多推荐
发布评论