我想从我在 Cookie 中拥有的名称的 CodeMirror 文本区域中获取值。我怎样才能做到这一点?
我试过:
var formname = $.cookie("formname");
var formcode = formname.getValue();
Firebug 说:formname.getValue 不是函数
非常感谢你。我希望你能理解我。
我想从我在 Cookie 中拥有的名称的 CodeMirror 文本区域中获取值。我怎样才能做到这一点?
我试过:
var formname = $.cookie("formname");
var formcode = formname.getValue();
Firebug 说:formname.getValue 不是函数
非常感谢你。我希望你能理解我。
formname
是一个字符串。字符串没有这种称为 的方法getValue
。看到 的外观$.cookie("formname")
,我假设您使用的是 JQUery。
代码:
var formname = $.cookie("formname");
var formcode = $('textarea[name="'+formname+'"]').val(); //JQuery method:
// Selects an input element whose name equals `formname` and gets the value of it.
//var formcode = document.getElementById(formname).value;
// Another method: Without use of JQuery, assuming that the textarea's id equals formname