我在創建單選按鈕克隆時遇到了IE7中的問題。我正在動態更新名稱和ID屬性,但是,我仍然有一個問題,即單選按鈕被重新設置,以重置其他動態創建的其他任何按鈕。任何想法如何可以解決? Here is a fiddle of the issue當動態創建IE7單選按鈕問題
這是JS代碼操縱表單字段:
// Dropdown select
$('#quantity').live("change", function(){
$('.questions_clonable:not(.questions_clonable:first)').remove();
// Get value of selection
var num = $(this).val();
var cloned_el = $('.questions_clonable').clone();
if (num > 1)
{
for (var i = 1; i < num; i++)
{
// Assign cloned block to new var
var new_block = cloned_el;
// Store previous number for replacing with current in cloned block input fields
var prev = i-1;
// Update input name to make it unique
new_block.find('input').each(function() {
this.name = this.name.replace(prev, i);
this.id = this.id + i;
});
// Bit of a workaround needed to clone properly, reiterating class name
$('.multiple_questions_container').append('<span class="questions_clonable hidden">'+new_block.html()+'</span>');
}
}
});