在滑块div中查找可见元素

时间:2013-07-30 11:31:48

标签: javascript jquery

我有一个非常标准的滑块组件,滑块UL。

我想将活动类仅添加到视口中的可见元素。我试着谷歌搜索,但所有都在vail。有人能够对此有所了解吗?

enter image description here

以下是滑动代码:

// get all lists that slider was initialised on
$lists = $(this.container).find('> ul');

// get current left position of list
currentPos = $lists.position().left;

// new left position of list is width of a page times target page number
newLeftPos = currentPos - (530 * (newPageNum-1));

1 个答案:

答案 0 :(得分:1)

if($("li").is(":visible")){
    $(this).addClass('active');
}
相关问题