我想设置一个单选按钮。我想通过使用值或ID来设置它。jQuery设置单选按钮
这是我试过的。
$('input:radio[name=cols]'+" #"+newcol).attr('checked',true);
newcol
是单选按钮的ID。
也许有点编辑是为了。
有两套无线电箱,其中一箱有一列,另一箱有行。所以我明白了不使用id的意义。我的错。所以,我有作为一个例子:
<input type="radio" name="rows" class="listOfCols"
style="width: 50%; " value="Site"></input>
和
<input type="radio" name="cols" class="listOfCols"
style="width: 50%; " value="Site"></input>
与ID的删除,而我需要设置正确的。
的可能重复[如何设置无线选项的onload检查与jQuery](http://stackoverflow.com/questions/871063/how-to-set-radio-option-checked-onload-with-jquery) – 2012-03-01 22:27:17
这就是我正在寻找克里斯。谢谢 – mike628 2012-03-02 20:54:31
@ mike628你应该接受其中一个答案! – 2014-01-05 20:20:33