在jQuery mobile中textarea的高度和宽度?

时间:2011-08-25 17:26:43

标签: javascript jquery html

我在jQuery mobile中修复了文本区域元素的高度,并且我在纵向中获得了完美的高度和宽度,但在横向中宽度不会放大。谁能帮我?提前谢谢。

HTML:        <textarea cols="55" rows="50" name="textarea" id="newMarkCompleteCommentText" style="background-color:White;width:95%;height: 50px;"></textarea>

IN JS:
    $('#newCommentText').attr('style', 'background-color:White;font-size:18px;height:7em;');

2 个答案:

答案 0 :(得分:2)

尝试设置“width:auto”。此外,而不是“.attr('style',...)”,你可以使用“.css('attribute','value')”

$('#newCommentText').css('background-color', 'white').css('font-size', '18px').css('height', '7em').css('width', 'auto');

答案 1 :(得分:1)

如果您要设置宽度和高度,则无需设置cols和rows。尝试删除这些值,textarea应该使用%值进行扩展。

此外,您的包含元素的textareas是否已设置为展开?

相关问题