无法将 class 更改为 jquery 和 waypoints

Can not change class with jquery and waypoints

我遇到了一个让我很沮丧的问题。我的body是这样的:

<div class='chapter'>
  <div class='side side-right'>
     <image src="./image1">
  <div>

  <div class='side side-left'>
     Chapter 1
  </div>
</div>

在 javascript 中,我有:

$(document).ready( function(){
$(".chapter").waypoint(function(e){
   if (e=="down" ) {$(this).find(".side-right").addClass("current");   console.log(e);}
   if (e=="up"   ) {$(this).find(".side-right").removeClass("current");console.log(e);}
}
);

不过,class好像没有变化。控制台根据我的滚动方式打印 "up" 或 "down",但我没有注意到 class 发生变化。

知道哪里出了问题吗?感谢您的帮助。

我正在使用 jquery.js 和 jquery.waypoints.js

K.

this 不是路点处理程序中的 HTML 元素,它是路点 class 的一个实例。要获取元素,请使用 $(this.element).