Aiswarya Krishna
Aiswarya Krishna

Reputation: 89

Mingle Javascript variable and DIV ID name in jQuery Selectory

I have a Javascript Variable as follows, which get it's DiV ID value.

var aishu=$(this).closest('div').parent().closest('div').attr('id');

Let's say, the value of variable aishu is std_1

Now I need to have a jQuery selector in the following form

$('#' + aishu #size).hide();

Which selects the DIV that is contained in the JS variable and select the dropdown with the ID 'size' inside it.

Upvotes: 0

Views: 80

Answers (1)

Milind Anantwar
Milind Anantwar

Reputation: 82241

You need to concatenate static selector as string:

$('#' + aishu +' #size').hide();

How ever IDs are always unique. You can simply use id selector for element with id=size:

$('#size').hide();

Upvotes: 1

Related Questions