繁体   English   中英

调整jHtml文本区域的大小

[英]Resize jHtml text area

我想像普通文本区域一样调整jHtml TextArea的大小,所以有没有办法调整大小。

以下是创建jHtml Textarea的代码。

这是HTML代码:

<table style="width: 100%; border-collapse: separate !important; border-spacing: 2px!important">
<tr>
    <td>
        <%=Html.LabelFor(m => m.Description)%>
    </td>
    <td>
        <%=Html.TextAreaFor(m => m.Description, new { @class="form-control",style="width: 610px; height: 150px" })%>
    </td>
</tr>
</table>

以下是javascript代码:

<script type="text/javascript">
   $(function () {
    $("#Description").htmlarea({
        // Override/Specify the Toolbar buttons to show
        toolbar: [
            ["bold", "italic", "underline", "|", "forecolor"],
             ["p", "h3", "h4", "h5", "h6"],
              ["link", "unlink", "|", "image"],
              ["orderedlist", "unorderedlist"],
              ["increasefontsize", "decreasefontsize"],
              ["indent", "outdent"],
              ["justifyleft", "justifycenter", "justifyright"],
              ["cut", "copy", "paste"]
        ]
    });
});
</script>

您可以通过添加jHtmlarea的“resizable”属性来实现该行为。 可以帮到你。

<script type="text/javascript">
   $(function () {
     $("#Description").htmlarea({           
          toolbar: [
             ["bold", "italic", "underline", "|", "forecolor"],
             ["p", "h3", "h4", "h5", "h6"],
             ["link", "unlink", "|", "image"],
             ["orderedlist", "unorderedlist"],
             ["increasefontsize", "decreasefontsize"],
             ["indent", "outdent"],
             ["justifyleft", "justifycenter", "justifyright"],
             ["cut", "copy", "paste"]
         ]
     }).parent().resizable({ alsoResize: $("#comm").find('iframe') });
  });
</script>

我的猜测是你可以通过使用css规则轻松实现所需的行为如下面的代码片段所示:

 #Comments { position:absolute; width:60%; height:200px; } 
 <textarea id="Comments">My text.</textarea> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM