选择输入标签 - 单击时选择中间日期
我目前拥有标准选择输入多年。目前,当单击时,它会显示一长串从 1900 年到 2000 年的年份列表,需要您向下滚动。
有没有办法让它在单击时出现在中间,以便您可以向上或向下滚动?
我希望这是有道理的!
I currently have a standard select input for years. Currently, when clicked, it presents a long list of years from 1900-2000, that require you to scroll down.
Is there a way to make it appear in the middle, when clicked, so that you can scroll up or down?
I hope this makes some sense!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用
selected
属性示例:http://jsfiddle.net/tnU4K/
use
selected
attributeexample: http://jsfiddle.net/tnU4K/
对于下拉
就我个人而言,我不会打扰。大多数用户都知道,无论如何,他们可以在聚焦
中选择选项。
For a drop down
<select>
element? Not in a standardized, cross browser way. Some browsers may (untested) allow you to manipulate thescrollTop
property of the select element while the list is visible, but I wouldn't count on it. The only way to start in the middle is have the middle year selected by default.Personally, I wouldn't bother. Most users know that they can type whilst focusing a
<select>
element anyway — I rarely use the mouse to select an option in a drop-down<select>
.在默认选择的中间(可能是 1950)附近设置一个值。当有人单击选择时,所选值将可见,因此您可以向上或向下滚动。
Make a value somewhere around the middle (maybe 1950) selected by default. When someone clicks the select the selected value will be visible, so you can scroll up or down.
你总是可以疯狂地使用 jquery 做这样的事情:
我还没有测试过,但它应该可以工作。
You could always go hog wild and do something like this using jquery:
I haven't tested but it should work.