php 如何在html中制作多行类型的文本框?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4518933/
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
How to make a textbox of multiple line type in html?
提问by Ahmad Farid
<input class="FormElement" name="term" id="term" type="text">
What modifications should I do to this textbox to make it multiple line, without the need to modify anything else in the code, like reading its value.
我应该对此文本框进行哪些修改以使其成为多行,而无需修改代码中的任何其他内容,例如读取其值。
I used to read the input by javascript like that, what should be changed in that as well?
我曾经像这样通过javascript读取输入,那也应该改变什么?
var $term = $("textarea#term").val();
回答by Nick Craver
You need a <textarea>
with the same name
, so replace this:
你需要一个<textarea>
相同的name
,所以替换这个:
<input class="FormElement" name="term" id="term" type="text">
With this:
有了这个:
<textarea class="FormElement" name="term" id="term" cols="40" rows="4"></textarea>
The rows
and cols
arguments are the width/height respectively...or use CSS styling to specify the size, like this:
在rows
和cols
参数是宽/高分别为...或使用CSS样式指定大小,就像这样:
<textarea class="FormElement" name="term" id="term" style="width: 200px; height: 40px;"></textarea>