I would like to do the following in JQuery:
var test = "'#ISP'";
alert($(test).val());
I get "Syntax error, unrecognized expression."
I know i am missing something here.
Thanks alot!
I would like to do the following in JQuery:
var test = "'#ISP'";
alert($(test).val());
I get "Syntax error, unrecognized expression."
I know i am missing something here.
Thanks alot!
你可以这样做
var test = "ISP";
alert($("#"+test).val());
或从您的表达式中取出额外的单引号
var test = "#ISP";
alert($(test).val());
工作样本:http: //jsfiddle.net/VwDyW/9/
您必须删除 "s 内的 's
var test = "#ISP";
alert($(test).val());