0

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

                    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>
4

2 回答 2

1

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

于 2010-09-20T20:51:21.833 回答
0

尝试做:

jQuery('#condition-'+r[i].condition_id+'-on_amazon').filter('[value='+r[i].on_amazon+']')[0].checked=true;
于 2010-09-20T20:52:37.390 回答