jQuery检查无线电选项不检查

时间:2010-09-20 20:48:53

标签: jquery jquery-1.3.2

我无法在我的页面上查看收音机选项。他们不会检查是或否。

                    for (var i = 0; i < r.length; i++) {
                        jQuery('#condition-'+i+'-price').val(r[i].price);
                        jQuery('#condition-'+i+'-bid').val(r[i].bid);
                        console.log('[value='+r[i].on_amazon+']');
                        console.log(jQuery('#condition-'+r[i].condition_id+'-on_amazon').filter('[value='+r[i].on_amazon+']'));
                        jQuery('#condition-'+r[i].condition_id+'-on_amazon').filter('[value='+r[i].on_amazon+']').attr('checked', true);
                    }

r [i] .on_amazon始终为1或0且condition_id正确,因为价格/出价成功更新...

<tr>
                            <td><label for="on_amazon-1-yes">Yes</label></td>
                            <td class="yes"><input type="radio" id="condition-1-on_amazon" value="1"></td>
                            <td>&nbsp;</td>
                            <td class="no"><input type="radio" id="condition-1-on_amazon" value="0"></td>
                            <td><label for="on_amazon-1-no">No</label></td>
                        </tr>

2 个答案:

答案 0 :(得分:1)

假设您使用的是XHTML,请设置$(radiobtn).attr('checked','checked')而不是true

答案 1 :(得分:0)

尝试做:

jQuery('#condition-'+r[i].condition_id+'-on_amazon').filter('[value='+r[i].on_amazon+']')[0].checked=true;