使用多个类的JQuery航点 [英] JQuery waypoints using multiple classes

查看:90
本文介绍了使用多个类的JQuery航点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 http://imakewebthings.com/jquery-waypoints 并在其上有5个类(员工)当到达头等舱时,所有航站楼将立即触发航路点.如何上演它,以便您通过列表时可以添加?

I'm using http://imakewebthings.com/jquery-waypoints and having 5 classes (staffmember), at the moment waypoints fires on all the classes at once when getting the first class. How to stage it so that I can add as you pass through the list?

<ul id="staff">
<li class="staffmember"></li>
    <li class="staffmember"></li>
    <li class="staffmember"></li>
    <li class="staffmember"></li>
    <li class="staffmember"></li>
</ul>

jQuery

$('.staffmember').waypoint(function(direction) {
jQuery('.staffmember').addClass('on').next();
});

谢谢

推荐答案

如果我理解您正确尝试此方法.它应该遍历每个.waypoint元素,并向每个添加单个.on类的航路点添加单独的航路点.

If I understand you correctly try this. It should iterate through each .waypoint element and add individual waypoints to each one that add the .on class as you scroll past them.

$('.staffmember').each(function() {
  $(this).waypoint(function() {
    $(this).addClass('on');
  });
});

这篇关于使用多个类的JQuery航点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆