我需要添加这个函数fadeInBoxes(); 作为此点击函数的回调。我无法获得适合我一生的语法。因此,在完成所有这些工作之后,我想在上面加载我的函数。有任何想法吗?
$(".select").click(function(){
fadeBoxes();
var num = $(this).attr('rel');
$("ul").roundabout("animateToChild", num);
chageDots(num);
});
完整代码
$(document).ready(function() {
function chageDots(dot){
for (var i = 0; i < 5; i++) {
$("#dot0"+i).removeClass("active");
};
$("#dot0"+dot).addClass("active");
};
var images = ["img1.jpg","img1.jpg","img1.jpg","img1.jpg","img1.jpg"];
for (var j = 0; j < 5; j++) {
$("#img0"+j).css("background-image","url('"+images[j]+"')");
$("#img0"+j).css("background-size","cover");
};
var fade_start=false;
chageDots(0);
$('ul').roundabout({
btnNext: '.next',
btnPrev: '.back',
btnNextCallback: function() {
var data = $(this).data("roundabout");
var current_num = data.childInFocus;
chageDots(current_num);
fadeInBoxes();
},
btnPrevCallback: function() {
var data = $(this).data("roundabout");
var current_num = data.childInFocus;
chageDots(current_num);
fadeInBoxes();
},
clickToFocusCallback: function(){
var data = $(this).data("roundabout");
var current_num = data.childInFocus;
chageDots(current_num);
current_num.click == false;
fadeInBoxes();
}
});
$(".next").click(function() {
fadeBoxes();
});
$(".back").click(function() {
fadeBoxes();
});
$("li").click(function() {
fadeBoxes();
});
$(".select").click(function(){
fadeBoxes();
var num = $(this).attr('rel');
$("ul").roundabout("animateToChild", num);
chageDots(num);
});
function fadeBoxes (){
if(fade_start != true){
fade_start = true;
$("#mainBox").fadeOut("fast",function() {
// Animation complete.
fade_start = false;
});
$("#leftBox").fadeOut("fast",function() {
// Animation complete.
fade_start = false;
});
$("#rightBox").fadeOut("fast",function() {
// Animation complete.
fade_start = false;
});
}
};
function fadeInBoxes (){
$("#mainBox").fadeIn(200);
$("#leftBox").fadeIn(100);
$("#rightBox").fadeIn(100);
};
});