Некоторое время я не занимался веб-дизайном, и кто-то попросил меня о помощи в воспроизведении этого эффекта: http://www.jetsetter.com/destinations/italy?nm=destinations
Я довольно близко здесь, с кем-то другим, но теперь я не могу заставить фон измениться. Он работает, когда я изменяю фоновый цвет, но не фоновое изображение.
Может кто-нибудь взглянуть и посмотреть, что я пропустил?
$(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
});
});
});
$(document.body).css({
'background-image': 'url(' + backgroundSrc + ')'
});
Настройка фонового изображения с использованием свойства CSS jQuery