使用 jquery 更改输入的大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11019746/
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
Change the size of input with jquery
提问by Steven Jones
I have the following input:
我有以下输入:
<input id="input_2_2"
class="medium"
type="file"
tabindex="4"
size="20"
value=""
name="input_2">
I don't have access to the HTML therefore I would like to apply jQuery to change the size to "60".
我无权访问 HTML,因此我想应用 jQuery 将大小更改为“60”。
Please can someone help?
请问有人可以帮忙吗?
回答by ayyp
$("input_2_2").attr("size", "60");
$("input_2_2").attr("size", "60");
回答by Tom O
Use this:
用这个:
$("#input_2_2").attr("size", "60");
I believe that should work..
我相信这应该有效..
回答by Ricardo Binns
use attr();
使用attr();
like this:
像这样:
<input id="input_2_2" class="medium" type="file" tabindex="4" size="20" value="" name="input_2">
<input id="input_2_2" class="medium" type="file" tabindex="4" size="20" value="" name="input_2">
$("#input_2_2").attr("size","60");
$("#input_2_2").attr("size","60");
or, you can just set the width
of the element, in my opinion it's better.
或者,您可以设置width
元素的 ,在我看来它更好。