更改< select>的宽度HTML中的项目 [英] Changing the width of a <select> item in HTML

查看:170
本文介绍了更改< select>的宽度HTML中的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是HTML新手,我正在尝试使用phoneGap和jQuery插件构建移动应用。我目前正在使用eclipse编程,在我的应用程序中,我有一个drop dwon菜单(选择),里面有几个项目。我试图改变选择项的宽度,但它不起作用。在这里你可以看到我做了什么来解决这个问题:

I am new to HTML, and I'm trying to build a mobile app using phoneGap and jQuery plug-in. I am currently programing using eclipse, In my app I have a drop dwon menu (select) with a couple of items in it. I am trying to change the width of the select item, but it doesnt work. here you can see what have i done to solve this:

<label for="select-choice-1" class="select">Choose Expiry Date</label>
        <select id="date" name="select-choice-1" id="select-choice-1" style="width:150px">
        <option value="">1</option>
        <option value="">2</option>
        <option value="">3</option>
        <option value="">4</option>
</select>


推荐答案

$('#date').css('width', 'new_Value');

来自jQuery Mobile Documentation:

From jQuery Mobile Documentation:

刷新选择

如果您通过JavaScript操作选择,则必须在其上调用refresh方法以更新视觉样式。这是一个例子:

If you manipulate a select via JavaScript, you must call the refresh method on it to update the visual styling. Here is an example:

var myselect = $("select#foo");
myselect[0].selectedIndex = 3;
myselect.selectmenu("refresh");

这篇关于更改&lt; select&gt;的宽度HTML中的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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