单选按钮在Chrome和IE中消失

时间:2010-11-19 09:47:34

标签: javascript jquery html-table radio-button

我有这个表格单元格,我通过jQuery添加一个单选按钮。它在Firefox中显示OK,但在Chrome或IE中不显示。 我正在粘贴这个最小化的版本(只是单个单选按钮的代码,而不是所有这些代码)

这是表格行:

        <tr>
        <td style="text-align: right; vertical-align:top">
            <strong>Hard drive type:</strong></td>
        <td id="custom_hddtype">
            </td>
    </tr>

这是javascript:

$('#custom_hddtype').append('<input type="radio" name="hddtype" id="'+products_custom['hddtype'][i]['id']+'" value="'+products_custom['hddtype'][i]['id'] />'+products_custom['hddtype'][i]['name']+'<br />');

有没有人知道为什么没出现这个?

2 个答案:

答案 0 :(得分:4)

您在这里错过了value属性的结尾引用:

value="'+products_custom['hddtype'][i]['id'] />

应该是:

value="'+products_custom['hddtype'][i]['id']+'" />
                                             ^^ missing

完成后,它应该看起来像这样:

$('#custom_hddtype').append('<input type="radio" name="hddtype" id="'+products_custom['hddtype'][i]['id']+'" value="'+products_custom['hddtype'][i]['id']+'" />'+products_custom['hddtype'][i]['name']+'<br />');

答案 1 :(得分:1)

尝试使用这个

$('#custom_hddtype').append('<input type="radio" name="hddtype" id="'+products_custom['hddtype'][i]['id']+'" value="'+products_custom['hddtype'][i]['id']+'" />'+products_custom['hddtype'][i]['name']+'<br />');
相关问题