首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JQuery航点帮助

JQuery航点帮助
EN

Stack Overflow用户
提问于 2013-11-15 10:12:52
回答 1查看 209关注 0票数 0

我已经离开网页设计很长一段时间了,有人向我寻求帮助来重现这种效果:http://www.jetsetter.com/destinations/italy?nm=destinations

在别人的帮助下,我离这里很近了,但现在我不能改变背景。当我改变背景颜色,而不是背景图像时,它就会起作用。

有没有人能看看我错过了什么?

http://jsfiddle.net/pfwwv/28/

代码语言:javascript
复制
$(document).ready(function(){
// attach a waypoint to each div.waypoint element
// the callback is executed every time the user scrolls past 
// see http://imakewebthings.com/jquery-waypoints/#docs
$('.waypoint').waypoint(function(direction){
    // you can use the direction parameter here to check which way the user was     scrolling if you need

    // get the background-image source from the data-src property on the DOM element
    var backgroundSrc = $(this).attr('data-src');

    // now update the CSS for the body
    $(document.body).css({
     'background-image': backgroundSrc
    });
 });

});

EN

回答 1

Stack Overflow用户

发布于 2013-11-15 10:28:29

代码语言:javascript
复制
$(document.body).css({
    'background-image': 'url(' + backgroundSrc + ')'
});

Setting background-image using jQuery CSS property

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19992292

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档