用于移动设备的 JQuery 下拉列表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7110611/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JQuery Dropdown list for mobile
提问by Paresh
I'm trying to make a dropdown selector using jquery. The selected option will set the date range for a chart which is rendered when the item is selcted.
我正在尝试使用 jquery 制作下拉选择器。所选选项将为图表设置日期范围,该图表在选择项目时呈现。
This needs to work on a mobile phone via phonegap.
这需要通过 phonegap 在手机上工作。
I have looked on JQuery UI, but there doesn't seem to be anything suitable I can use.
我看过 JQuery UI,但似乎没有任何适合我可以使用的东西。
Is there anything you guys (and gals) could recommend?
你们(和女孩)有什么可以推荐的吗?
回答by Norman Joyner
If you are looking for something that functions similarly to a regular select element and is optimized for mobile applications, you should check out jQuery Mobile Select Menus. Using jQuery mobile with PhoneGap is a simple way to create a mobile application UI.
如果您正在寻找功能类似于常规选择元素并针对移动应用程序进行优化的东西,您应该查看jQuery Mobile 选择菜单。将 jQuery mobile 与 PhoneGap 结合使用是创建移动应用程序 UI 的一种简单方法。
Hope this helps.
希望这可以帮助。
回答by yesh
I would suggest you to go with a simple Select element and keep it as simple as possible. Since you have mentioned you will be using the selected value i would suggest you to do some thing like this.
我建议您使用一个简单的 Select 元素并使其尽可能简单。既然你已经提到你将使用选定的值,我建议你做一些这样的事情。
<script type = text/javascript>
$(function(){
$('#number').bind('change', function(){
display();
});
});
function display(){
$('#display').html('');
var number = $('#number');
// now this variable stores the value you need you can use this !!
$('#display').append( '<p>' number '</p>');
}
</script>
<form method="get" name="datarange">
<select id="number" name="value you need">
<option value="select-value" selected="selected">Select A value</option>
<option value="atlanta"> 1 </option>
.....
</select>
</form>
<div id="display" class="rss-box"></div>
</div>
回答by Shazron
Try chosen : http://harvesthq.github.com/chosen/