当我单击一些箭头(基本上是滑块)时,我有一段代码会更改 div 的类,但我找不到 jquery 代码,尽管它会监听类何时更改并执行动画。例如,我需要它来执行此功能。
if(*classname* == slide1){
//************ Background Settings *************
$(".background").css('background','url("img/park.png")')
//************ slide 1 Animations *************
$(".s1").animate({
opacity:1
},500)
$("#header1").animate({
opacity:1
},500)
$("#p1").animate({
opacity:1
},500)
$("#image1").animate({
left:140
},1000)
}
我的班级更改代码是这样的
var page_number = 0
function next(){
var current_slide = page_number;
if(current_slide == 0){
$("section").removeClass('starterslide').addClass('slide2')
page_number = 2
}
else if(current_slide == 1){
$("section").removeClass('slide1').addClass('slide2')
page_number = 2
}
else if(current_slide == 2){
$("section").removeClass('slide2').addClass('slide3')
page_number = 3
}
else if(current_slide == 3){
$("section").removeClass('slide3').addClass('slide1')
page_number = 1
}
}
function back(){
var current_slide = page_number;
if(current_slide == 0){
$("section").removeClass('starterslide').addClass('slide3')
page_number = 3
}
else if(current_slide == 1){
$("section").removeClass('slide1').addClass('slide3')
page_number = 3
}
else if(current_slide == 2){
$("section").removeClass('slide2').addClass('slide1')
page_number = 1
}
else if(current_slide == 3){
$("section").removeClass('slide3').addClass('slide2')
page_number = 2
}
}