如何更改textarea的大小(宽度/高度)或动态只读的文本?

时间:2013-08-22 10:32:08

标签: jquery django textarea

我有一个django模型,其中包括几个只读的textareas和文本。例如:

class FormTask(forms.Form):
     name = forms.CharField(required = False, max_length = 300, 
                widget = forms.TextInput(attrs = {"readonly" : "readonly"}),
                label = "task name")
     id = forms.CharField(required = False, max_length = 300, 
                widget = forms.TextInput(attrs = {"readonly" : "readonly"}),
                label = "task ID")
     script = forms.CharField(required = False, max_length = 2000, 
                widget = forms.Textarea(attrs = {"readonly" : "readonly"}),
                label = "task script")

当我使用jquery将模型渲染到html页面时,我发现textarea(脚本)无法填充命令,而且这个textarea是readonly,所以我想动态地改变它的大小。如果我想改变它的尺寸,你能告诉我该怎么办吗?非常感谢你!

1 个答案:

答案 0 :(得分:0)

$("#textareaID").width(123);// by this 123 px width set
$("#textareaID").height(123);// by this 123 px height set

参考

height

width