2010-11-19 48 views
0

我有這個表格單元格,我通過jQuery追加單選按鈕。它在Firefox中顯示正常,但不顯示在Chrome或IE中。 我粘貼在這個最小化版本單選按鈕消失在Chrome和IE中

這裏(只是一個單選按鈕,而不是全部的代碼)的The錶行:

 <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 />'); 

有沒有人知道爲什麼不顯示出來?

+0

變量的值是什麼?換句話說,生成的HTML是什麼?你確定生成有效的HTML嗎? – kgiannakakis 2010-11-19 09:50:40

回答

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 />'); 
+0

aaaaahhhhrrrr ...我討厭它發生這種情況!謝謝一堆。我希望它不會起作用,或者至少Firebug會指出一些東西。 – donkapone 2010-11-19 10:18:58

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 />');