我有一个<div>
与选项框:如何获取所选单选按钮的值?
<div id='RB-01'>
<span>Item_1</span><input type='radio' name='RB01' value='1'><br />
<span>Item_2</span><input type='radio' name='RB01' value='2'><br />
<span>Item_3</span><input type='radio' name='RB01' value='3'><br />
</div>
然后用jQuery
我想要得到数量上的帐户进行查了radiobox:
var obj;
var tempId = "RB-01";
if ($('div[id=' + tempId + ']')) {
$('div[id=' + tempId + '] input').each(function() {
...here I need save in the variable obj the number on an account input that was checked...
});
}
@PabloFernandez:你的代码将无法通过JSLint的,你需要使用''=== – qwertymk
@qwertymk如此真实。但正如Brendan Eich自己所说:“jslint可以吸引它” –