user624365
user624365

Reputation: 3

jQuery - Trouble passing a variable into input:radio[name]

I'm having trouble passing a variable in the following

var whichRbClicked = $('input:radio[name=RBname]:checked').val();

where RBname is the variable.

Any help or advise would be MUCH appreciated. TIA

Upvotes: 0

Views: 1167

Answers (1)

Sarfraz
Sarfraz

Reputation: 382816

Should be:

var whichRbClicked = $('input:radio[name=' + RBname + ']:checked').val();

For more info, check out:

Upvotes: 2

Related Questions