1

我正在使用 jQuery mobile,我有一个长长的无序列表,如下所示:

<div id="wrapper" />
<div id="scroller" />
<div class="trans" />
<ul id="thelist" data-corners="false" 
<div class="theListItem" data-role="collapsible-set" data-collapsed="false">
    <div data-role="collapsible" class="my-collapsible" data-collapsed="false" data-theme="a" data-iconpos="right">
        <h3>$111.58   -  10/30/2012   -   McDonalds Restaurant  -  Chicago Il</h3>
        <div data-role="controlgroup" data-type="horizontal">
            <a class="green" href="categorize.html" data-transition="slide" data-direction="reverse" data-role="button">Yes</a>
            <a class="red" href="#" data-role="button">Not deductible</a>
            <a class="blue" href="IDontKnow.html" data-transition="slide" data-role="button">I don't know</a>
        </div>
        <div data-role="collapsible" class="my-collapsible" data-collapsed="false" data-theme="a" data-iconpos="right">
            <h3>$111.58   -  10/30/2012   -   McDonalds Restaurant  -  Chicago Il</h3>
            <div data-role="controlgroup" data-type="horizontal">
                <a class="green" href="categorize.html" data-transition="slide" data-direction="reverse" data-role="button">Yes</a>
                <a class="red" href="#" data-role="button">No</a>
                <a class="blue" href="IDontKnow.html" data-transition="slide" data-role="button">I don't know</a>
            </div>
            <div data-role="collapsible" class="my-collapsible" data-collapsed="false" data-theme="a" data-iconpos="right">
                <h3>$111.58   -  10/30/2012   -   McDonalds Restaurant  -  Chicago Il</h3>
                <div data-role="controlgroup" data-type="horizontal">
                    <a class="green" href="categorize.html" data-transition="slide" data-direction="reverse" data-role="button">Yes</a>
                    <a class="red" href="#" data-role="button">No</a>
                    <a class="blue" href="IDontKnow.html" data-transition="slide" data-role="button">I don't know</a>
                </div>
            </div>
            </ul>
        </div>
    </div>
</div>

而且,我正在努力做到这一点,以便当我单击任何列表项时,该列表项会突出显示并滚动到我的视口顶部,就在标题下方。有任何想法吗?

4

2 回答 2

0

查看$.scrollTo()插件和 jQuery UIhighlight功能。

也检查这个问题,它有一个很好的滚动到元素的解决方案:jQuery scroll to element

http://demos.flesler.com/jquery/scrollTo/

http://docs.jquery.com/UI/Effects/Highlight

于 2013-01-09T15:33:52.023 回答
0

试试这个:

$('a').click(function(){
    $("#scroller").css('top','0');
});
于 2013-01-09T16:17:55.260 回答