开发者

how to add a # to a var

Hi h have some code which brin开发者_开发知识库gs back the class name of a link

var activeTab = $(this).attr("class"); 

so lets say the above brings back a value of 'one'

i need to append this to be #one for the below code

var activeTab = $(this).attr("class"); 
          $(activeTab).stop(true, false).animate({ height: "200px" });  

thanks in advance


Very simple in Javascript:

var_name = '#' + var_name;


You can use + for string concatenation:

$('#' + activeTab)


You can use + operator for string concatenation like this:

$('#' + activeTab)


var activeTab = $(this).attr("class"); 
activeTab = '#' + activeTab;
$(activeTab).stop(true, false).animate({ height: "200px" });


$('#' + activeTab) ....

?!

var activeTab = $(this).attr("class"); 
$("#" + activeTab).stop(true, false).animate({ height: "200px" });


var activeTab = "#" + $(this).attr("class"); 
$(activeTab).stop(true, false).animate({ height: "200px" });  

I think that's what you want to do.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜