I have to keep the value of textarea into hidden field using jquery.When I write "alert('yes');" inside textbox I want it display just as string but it is throwing an alert.How to make enable to take the html tag as string in jquery.In other words I want to take tags as string from 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();
This works but then the textarea will vanish and div taje the html.
这可以工作,但然后textarea将消失并分析html。
1 个解决方案
#1
0
I think your last line seems wrong You have done $("#bedtype").text(addbedtype).html();
Instead you need to do
我认为你的最后一行似乎错了你做了$(“#bedtype”)。text(addbedtype).html();相反,你需要这样做
$("#bedtype").html(addbedtype).text();
#1
0
I think your last line seems wrong You have done $("#bedtype").text(addbedtype).html();
Instead you need to do
我认为你的最后一行似乎错了你做了$(“#bedtype”)。text(addbedtype).html();相反,你需要这样做
$("#bedtype").html(addbedtype).text();