我正在使用一个名为Background担架的jQuery插件,这是对其进行初始化的代码。网站开始挂起我按回调函数中的链接越多,所以有更好的方法可以写这个...
$(document).ready(function(){
// Initialize Backgound Stretcher
$('BODY').bgStretcher({
images: ['images/exterior.jpg', 'images/exterior2.jpg','images/kitchen.jpg','images/bathroom.jpg','images/bedroom.jpg'],
imageWidth: 1800,
imageHeight: 1400,
slideDirection: 'N',
slideShowSpeed: 1000,
nextSlideDelay: 6000,
transitionEffect: 'fade',
sequenceMode: 'normal',
buttonPrev: '.prev',
buttonNext: '.next',
pagination: '.pagination',
anchoring: 'left center',
anchoringImg: 'left center',
callbackfunction: function() {
$('a#design').click(function(){
$().bgStretcher._clearTimeout();
$().bgStretcher.slideShow('normal', 0);
$().bgStretcher.play();
});
$('a#interior').click(function(){
$().bgStretcher._clearTimeout();
$().bgStretcher.slideShow('normal', 1);
$().bgStretcher.play();
});
$('a#lifestyle').click(function(){
$().bgStretcher.pause();
$().bgStretcher.slideShow('normal', 2);
$().bgStretcher.play();
});
$('a#location').click(function(){
$().bgStretcher.pause();
$().bgStretcher.slideShow('normal', 3);
$().bgStretcher.play();
});
$('a#contact').click(function(){
$().bgStretcher.pause();
$().bgStretcher.slideShow('normal', 4);
$().bgStretcher.play();
});
}
});
});
什么是更有效/更清晰的方式来写这个?
答案 0 :(得分:0)
您应该写$()
而不是$('body')
,所以请尝试以这种方式使用它:
.
.
.
// Initialize Backgound Stretcher
$('body').bgStretcher({
.
.
.
.
$('a#design').click(function(){
$('body').bgStretcher._clearTimeout();
$('body').bgStretcher.slideShow('normal', 0);
$('body').bgStretcher.play();
});
.
.
.