在jquery中处理类更改的最佳方法是什么?好像div将类从Active更改为不是。基本上我试图在div处于活动状态时以及当它不执行其他操作时附加一些代码
If div active {
do this
}
When not active {
do this
}
答案 0 :(得分:1)
使用active
.hasClass()
类
if ($('section1').hasClass('active') || $('section2').hasClass('active')) {
$('#fp-nav').animate({ "right": "0px" }, 2000 );
} else {
$('#fp-nav').animate({ "right": "-155px" }, 2000 );
}