开发者

How do I force a scrollbar in a <select> to go to the top of the list?

开发者 https://www.devze.com 2022-12-23 17:43 出处:网络
I have this HTML: <select multiple=\'multiple\' size=\'3\'> <option>1</option> <option&开发者_开发问答gt;2</option>

I have this HTML:

<select multiple='multiple' size='3'>
    <option>1</option>
    <option&开发者_开发问答gt;2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
</select>

Using jQuery how do I force the scrollbar in the select to go to the top?


$("select").scrollTop(0)

Should work, and, depending upon your browser, might work. But I would not count on it. It does not work in Safari 4, but does work in Firefox 3.5.9

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号