jQuery使用变量隐藏/显示div

我是jQuery的nOOb。

我想在jQuery中使用变量来隐藏/显示div。

到目前为止我所拥有的是:

$(document).ready(function(){ $('#listMenu a').click(function () { var getPage = $(this).attr("id"); var getName = $(this).attr("name"); //console.log(getPage); //console.log(getName); $("#" & getName ).show(); }); }); 

firebug控制台显示我有正确的vars,但我接下来会收到此错误:

[H] .style未定义[打破此错误](function(){var R = /((?:((?:( [^()] +)… typeof K ===“string” ?K:K + “PX”)}})})();

任何帮助表示赞赏。 SJS

我想你想写

 $("#" + getName ).show(); 

&不是javascript中的运算符,但+是。

使用$("#" + getName ).show();

+将连接字符串。