无法使用jquery读取@Html.TextArea
我尝试了很多方法,但无法使用jquery将值分配给无法使用jquery读取@Html.TextArea,jquery,asp.net-mvc-3,razor,Jquery,Asp.net Mvc 3,Razor,我尝试了很多方法,但无法使用jquery将值分配给@Html.TextArea 我试过了 $("#taeditor").attr("value", "testing"); $("#taeditor").val("testing"); $("#taeditor").html("testing"); 但是什么都不管用,如果你有任何线索,请帮忙。你需要像 @Html.TextArea("Textarea", new { id = "testing"}) 然后使用 $("#testing").val
@Html.TextArea
我试过了
$("#taeditor").attr("value", "testing");
$("#taeditor").val("testing");
$("#taeditor").html("testing");
但是什么都不管用,如果你有任何线索,请帮忙。你需要像
@Html.TextArea("Textarea", new { id = "testing"})
然后使用
$("#testing").val();
请在您的问题中提供呈现的html。您可以显示
@html.TextArea
的代码吗?我敢打赌您使用的ID不正确。。。尝试$(“textarea”).val(“测试数据文本”)代码>。如果这不起作用,jQuery要么没有被加载,要么代码没有被包装在一个文件中。下面是呈现的html@html.TextArea(“page”,htmlAttributes:new{@class=“ckeditor”,onchange=“return this;”,@id=“taeditor”})我看到当我分配类ckeditor时,它正在解决问题。现在,ckeditor基本上是通过附加的格式化控件来转换textaria。感谢您的回答,虽然这是可行的,但是ckeditor类在我的textaria上遇到了问题