我正在尝试动态复制一些单选按钮,但由于某种原因无法选择克隆的单选按钮......有人可以帮助我吗?
HTML
<div id="sGroup">
<div class="section" id="section1">
<input type="text" size = "16" id="section1" placeholder="Section Name"/>
<p id="par1"><textarea rows="2" cols="70" id="info1"/></textarea></p>
</div>
<div class="mediasection" id="mediasection1">
<input type="text" size ="50" id="url1" placeholder="Media URL"/>
<input type="radio" name ="media1" id="image1"/> Image
<input type="radio" name ="media1" id="video1"/> Video
</div>
</div>
JavaScript
function addMedia() {
var clonemedia = $("mediasection1").cloneNode(true);
clonemedia.setAttribute("id", "mediasection"+secCount);
//mediasection1 and mediasection2
var allRadio = clonemedia.querySelectorAll("input");
allRadio[0].setAttribute("id", "url"+secCount);
allRadio[1].setAttribute("name", "media"+secCount);
allRadio[1].setAttribute("id", "image"+secCount);
allRadio[2].setAttribute("name", "media"+secCount);
allRadio[2].setAttribute("id", "video"+secCount);
clonemedia.appendChild(allRadio[0]);
clonemedia.appendChild(allRadio[1]);
clonemedia.appendChild(allRadio[2]);
$("sGroup").appendChild(clonemedia);
}