开发者

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

开发者 https://www.devze.com 2023-02-11 21:35 出处:网络
I\'m havin开发者_如何转开发g trouble passing a variable in the following var whichRbClicked = $(\'input:radio[name=RBname]:checked\').val();

I'm havin开发者_如何转开发g 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


Should be:

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

For more info, check out:

  • Concatenating strings with the + operator
0

精彩评论

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