我正在使用JGallery plugin作为我的相册。我的代码是这样的:
<div id="gallery">
</div>
<script type="text/javascript">
document.querySelector('#gallery').appendChild(JGallery.create([{
title: 'Images',
items: [
{
url: 'images/large/1.jpg',
thumbUrl: 'images/thumbs/1.jpg',
title: 'Photo1',
hash: 'photo-1'
},
{
url: 'images/large/2.jpg',
thumbUrl: 'images/thumbs/2.jpg',
title: 'Photo2',
hash: 'photo-2'
},
{
url: 'images/large/3.jpg',
thumbUrl: 'images/thumbs/3.jpg',
title: 'Photo3',
hash: 'photo-3'
}
]
}, {
title: 'images2',
items: [
{
url: 'images/large/4.jpg',
thumbUrl: 'images/thumbs/4.jpg',
title: 'Photo4',
hash: 'photo-4'
},
{
url: 'images/large/5.jpg',
thumbUrl: 'images/thumbs/5.jpg',
title: 'Photo5',
hash: 'photo-5'
},
{
url: 'images/large/6.jpg',
thumbUrl: 'images/thumbs/6.jpg',
title: 'Photo6',
hash: 'photo-6'
}
]
}]).getElement());
</script>
我有7张专辑。我的目标是当我单击链接时,应该显示第三张专辑,并且还应该启用自动启动功能。我读了documentation。它是这样写的:
JGallery.create(albums,{
"autoStartAtAlbum": 2
});
所以,我写了;该代码:
$("#goto-product-alb3").on("click",function(e){
e.preventDefault();
$('html, body').animate({
scrollTop: $("#gallery").offset().top
}, 600);
JGallery.create(albums,{
"autoStartAtAlbum": 2
});
});
但我遇到了错误:
Uncaught ReferenceError: albums is not defined
不幸的是,文档不够清晰。我想念什么?