Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery [name=var] substitution

Tags:

jquery

Is there a way to use a variable in the name= parameter.

I would like to be able to do:

var a = 1;

$("#gen_p").html($("input:radio[name='gen'+a]:checked").val()));

I am able to do $("#gen_p"+a) but not in the [name=??]

Have I missed something?

Thanks

like image 735
Ian Avatar asked Jan 19 '26 15:01

Ian


1 Answers

$("#gen_p").html($("input:radio[name='gen"+a+"']:checked").val());​​

You're mixing some single quotes in there.

EDIT: You were also having some extra ) in there.

like image 124
Ben Avatar answered Jan 22 '26 04:01

Ben



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!