开发者

Textarea in chrome only shows one line

开发者 https://www.devze.com 2023-01-13 02:39 出处:网络
Hi I have a form with a text area for comments. The problem is my code below should produce a textbox 3 rows high but when it is displayed in Chrome it only ever appears as one line , Can anyone sugge

Hi I have a form with a text area for comments. The problem is my code below should produce a textbox 3 rows high but when it is displayed in Chrome it only ever appears as one line , Can anyone suggest what I am doing wrong please?

<tr>    
    <td >&nbsp;</td>
    <td ><strong>App开发者_开发问答rover Comments</strong></td>
    <td colspan="3" >
    <textarea name="approvecom" cols="100" rows="5" autocomplete="OFF"></textarea>
    </td>
    <td >&nbsp;</td>
</tr>


Try using height and width CSS definitions to define the bounds of your textarea instead.

<textarea style="height:100px; width:300px;"></textarea>


I'd go with a dynamic solution using jQuery:

$("textarea").each(function(){
  var rows = $(this).attr('rows');
  var newHeight = rows * 30;
  $(this).css({
    "height": newHeight + 'px'
  });
});
0

精彩评论

暂无评论...
验证码 换一张
取 消