开发者

How can I pass a variable and a string into the same jQuery selector?

开发者 https://www.devze.com 2023-01-11 22:16 出处:网络
I have the following: var x = \'.\'+this.id; and this does not work: $(x,\'#thumb\').show(); but this does:

I have the following:

var x = '.'+this.id;  

and this does not work:

$(x,'#thumb').show();

but this does:

$(x).show();

and obviously so does this:

$('#thumb').show();

What am I missing? Should I be doing something else in gener开发者_如何学Pythonal to pass variables (even on their own) through jQuery?


You need to concatenate the two strings together:

$(x+',#thumb').show();
0

精彩评论

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