如何改变Html的高度.我试过用jQuery,但是失败了

本文关键字:jQuery 失败 何改变 改变 高度 Html | 更新日期: 2023-09-27 18:18:48

我一直在研究asp.net mvc。我遇到了一个问题。我有一个多行文本框。我想增加它的高度。我试过使用@html。raw方法,并尝试在html . editfor中使用新的{styles:}添加内联样式,但没有效果。怎么做呢,这是我的View

   @model CTCFremont.Models.eMail
@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script>
    $(document).ready(function () {
        $("#PrayerRequest").css("height", 300);
        $("#PrayerRequest").css("width", 200);
    });
</script>
<h2>Submit Your Prayer Request</h2>
@using (Html.BeginForm()) {
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>eMail</legend>
        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Email)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Email)
            @Html.ValidationMessageFor(model => model.Email)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Request)
        </div>
        <div class="editor-field"  >
            @Html.EditorFor(model => model.Request,Html.Id("PrayerRequest"))
            @Html.ValidationMessageFor(model => model.Request)
        </div>
        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}
<div>
    @Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

如何改变Html的高度.我试过用jQuery,但是失败了

不确定要为哪个编辑器使用textarea,但只需使用以下代码来指定CSS样式中的高度。

@Html.TextAreaFor(x => x.Request, new {@style = "height: 30px;"})