我需要通過jQuery動態生成單選按鈕或複選框。
我使用以下代碼:jQuery中動態生成的單選按鈕不能在IE6中選擇
var type = "radio"; // maybe checkbox
$('<input type="'+ type +'">').attr({
name: "ename", value: "1"
})
然而,生成的無線電不能在IE6選擇(其他瀏覽器是細)。 我該怎麼辦?
marcc的答案解決了我的問題。
我需要通過jQuery動態生成單選按鈕或複選框。
我使用以下代碼:jQuery中動態生成的單選按鈕不能在IE6中選擇
var type = "radio"; // maybe checkbox
$('<input type="'+ type +'">').attr({
name: "ename", value: "1"
})
然而,生成的無線電不能在IE6選擇(其他瀏覽器是細)。 我該怎麼辦?
marcc的答案解決了我的問題。
這是IE6的工作方式,您不能在動態創建的元素上設置Name屬性。
在attr之前設置Name屬性。
$('<input type="' + type + '" name="ename">').attr('value', '1');
甚至
$('<input type="' + type + '" name="ename" value="1">');
我只是測試它,它的工作原理。 我之前閱讀此帖以創建輸入元素: http://stackoverflow.com/questions/702925/creating-dynamic-radio-button-w-jquery 我想我需要發佈響應以提醒人們對這個。 – Billy 2009-06-30 03:29:44
你是如何將其附加到文件? – 2009-06-30 03:13:42