[英]html tags as string in jquery
我必須使用jquery將textarea的值保留在隱藏字段中。當我編寫“ alert('yes');”時 在文本框內,我希望它以字符串形式顯示,但是會引發警報。如何在jQuery中啟用將html標簽作為字符串。換句話說,我想從jQuery中將標簽作為字符串。
<div id=bedtype">
@Html.TextAreaFor(x => x.AddBedTypeInfo, new { @placeholder = "additional bed type info", @class = "textareaWidth" })
</div>
$("#bedtype").text(addbedtype).html();
這有效,但隨后textarea將消失,並且將html分開。
我認為您的最后一行似乎有誤。您已經完成了$("#bedtype").text(addbedtype).html();
相反,您需要做
$("#bedtype").html(addbedtype).text();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.