【问题标题】:Enable TextArea for editing with JQuery [closed]启用 TextArea 以使用 JQuery 进行编辑 [关闭]
【发布时间】:2021-03-02 22:42:57
【问题描述】:

当我单击“Editar”按钮时,我需要它允许编辑 TextArea。我尝试了下面的代码,但没有任何反应。我试过道具、removeAttr、removeProp。全都一样。没有任何变化。

@using (Html.BeginForm("SalvarJustificativa", "Riscos"))
{
    @Html.AntiForgeryToken()
    <input type="text" name="co_tratamento_risco" id="co_tratamento_risco" value="@item.co_tratamento_risco" hidden />
    <div class="modal-body">
        <div class="md-form">
            <label for="tx_justificativa " class="mb-4 triangulo">Digite sua justificativa:</label>
            @Html.TextArea("tx_justificativa", @item.tx_justificativa, new { @class = "md-textarea form-control", @id = "tx_justificativa", @maxlength = "500", @style = "min-width: 100%", @rows = "5", @readonly = "true" })
        </div>
    </div>
    <div class="modal-footer">
        <button id="btnEditarJust" type="button" class="btn btn-danger mt-4">Editar</button>
        <button id="btnSalvarJust" type="submit" class="btn btn-success mt-4" >Salvar</button>
    </div>
}
$(document).ready(function () {
    $("#btnEditarJust").click(function () {
        $("tx_justificativa").removeAttr("readonly");

    });
});

【问题讨论】:

    标签: javascript c# html jquery


    【解决方案1】:

    $("tx_justificativa") 将尝试查找如下所示的 DOM 元素:&lt;tx_justificativa&gt;

    您需要改用$("#tx_justificativa")# 按 id 查找元素。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-20
      相关资源
      最近更新 更多