同一页面上有多个iScroll元素 [英] Multiple iScroll elements on same page

查看:114
本文介绍了同一页面上有多个iScroll元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个带有jQtouch和iScroll的移动网站。

I'm making a mobile website with jQtouch and iScroll.

我不想用iScroll获得多个可滚动区域,但只有列表适用于iScroll ...

I wan't to get multiple scrollable areas with iScroll, but only of the lists works with iScroll...

我试过这个:

var scroll1, scroll2;
function loaded() {
   scroll1 = new iScroll('wrapper');
   scroll2 = new iScroll('list_wrapper');
}

但没有运气。
任何人都有一个有效的解决方案吗?

But without luck. Anyone have a solution that's working?

我的html:

<div id="wrapper">
    <ul>
        <li><a href="#">Test</a></li>
    </ul>
</div>

<div id="list_wrapper">
    <ul>
        <li><a href="#">Test</a></li>
    </ul>
</div>


推荐答案

我正在使用这种方法。

Html:

<div class="carousel" id="alt-indie">
    <div class="scroller">
        <ul>
            <li></li>
            // etc
        </ul>
    </div>
</div>

JS:

$('.carousel').each(function (index) {
    new iScroll($(this).attr('id'), { /* options */ });
});

所以任何带有carousel类的东西都会成为滑块。

so anything with the class of "carousel" will become a slider.

这篇关于同一页面上有多个iScroll元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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