I am having some issues with Microsoft Explorer 6/7 and the jQuery "clone" function. The jQuery that I am using is:
我在使用Microsoft Explorer 6/7和jQuery“clone”功能时遇到了一些问题。我正在使用的jQuery是:
$(function() {
$('#addFields').click(function() {
var newCredit = $('#original').clone(); // create new set
newCredit.find('input').val(''); // empty input fields
$(this).before(newCredit); // append at the end
return false;
});
});
The html form looks like this:
html表单如下所示:
The Microsoft browser is unable to replicate more than one clone, and does not style (css) the new elements.
Microsoft浏览器无法复制多个克隆,也不能设置(css)新元素的样式。
Please advise me to a IE friendly alternative! Thanks.
请告诉我IE友好的替代方案!谢谢。
1 个解决方案
#1
You can't/shouldn't have elements without a parent
. Furthermore, you can't/shouldn't have
elements inside the like you have. Finally, you have id attributes in the HTML that is being cloned, and this will result in duplicate elements with the same id. If you replace the outer original div and make it a
, get rid of the id attributes and make it a class instead, it should be fine.