你好我的元素我有一个背景图片
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
}
);
});
最佳答案
$(document).ready(function () {
$(".boxy").hover(function () {
$("body").css('backgroundImage', 'url(img/2.JPG)');
}, function () {
$("body").css('backgroundImage', 'url(img/1.JPG)');
});
});
关于javascript - jQuery悬停在固定位置更改背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23294425/