gpt4 book ai didi

javascript - 使用 Jquery 将文本框值附加到 Summernote Textarea

转载 作者:行者123 更新时间:2023-12-03 02:04:38 25 4
gpt4 key购买 nike

我刚开始使用 Summernote Textarea ,并且在向 Summernote Textarea 传递值时遇到困难。尝试使用传统的 .html()、.text() 和 .val() 来传递下拉列表的值并将其附加到文本区域内。这是我的代码集

 $("#btnAddVariable").click(function (e) {
var eVariable = $("#EmailVariable option:selected").val();
$("#EmailMessage").val(eVariable);
$("#EmailMessage").text(eVariable);
alert(eVariable);
})

我的下拉列表

<div class="form-group">
@Html.LabelFor(model => model.EmailVariable, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-6">
@Html.DropDownListFor(model => model.EmailVariable, new SelectList(ViewBag.emailVariables, "Value", "Text"), "Please Select", htmlAttributes: new { @class = "form-control" })
@* @Html.DropDownList(model => model.EmailVariable, new SelectList(ViewBag.emailSender, "Value", "Text"), "Please Select", htmlAttributes: new { @class = "form-control" })*@

</div>
<div class="col-md-2">
<input type="button" id="btnAddVariable" value="Add Variable" class="btn btn-primary chosen" />
</div>
</div>

和我的 Summernote 文本区域

<div class="form-group">
@Html.LabelFor(model => model.EmailMessage, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-8">
<div class="ibox-content no-padding">
@Html.TextAreaFor(model => model.EmailMessage, new { @class = "summernote", rows = "5", cols = "90" })
</div>
</div>
</div>

希望有人能帮助我解决这个问题。提前致谢

Image

最佳答案

解决方案如下:

 $("#btnAddVariable").click(function (e) {
var eVariable = $("#EmailVariable option:selected").val();
$("#EmailMessage").val(eVariable);
$(".summernote").summernote('code',eVariable); //add text to summernote
alert(eVariable);
});

关于javascript - 使用 Jquery 将文本框值附加到 Summernote Textarea,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49849078/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com