开发者

Variable before CodeMirror function?

开发者 https://www.devze.com 2023-04-05 21:59 出处:网络
I want to get Value from CodeMirror textarea whose name I have in Cookie. How can I do this? I tried: var formname = $.cookie(\"formname\");

I want to get Value from CodeMirror textarea whose name I have in Cookie. How can I do this?

I tried:

  var formname = $.cookie("formname");
  va开发者_JAVA技巧r formcode = formname.getValue(); 

Firebug says: formname.getValue is not a function

Thank you very much. I hope you understand me.


formname is a string. A string does not have such a method called getValue. Seeing the appearance of $.cookie("formname"), I assume that you're using JQUery.

Code:

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
0

精彩评论

暂无评论...
验证码 换一张
取 消