我创建 vml 元素 v:shape,添加样式和属性,然后附加它。
var shape = document.createElement("v:shape");
//some attrs
shape.setAttribute("coordorigin", "0 0");
shape.setAttribute("coordsize", w + " " + h);
shape.setAttribute("stroked", "false");
//...
//some styles
shape.style.position = "absolute";
shape.style.top = 0 + "px";
shape.style.left = 0 + "px";
shape.style.width = w + "px";
shape.style.height = h + "px";
//...
$(element).append(shape);
我想将相同的形状附加到另一个地方
var shape2 = $(shape).clone(true);
但它只克隆样式
alert(shape2.css("position")); // absolute
alert(shape2.attr("coordsize")); // undefined
我该怎么办?请帮助我)
[编辑]
感谢您的回答)这对我来说很奇怪......我注意到当我将它附加到元素时它可以工作如果var element = document.createElement("p");
但我得到我的元素$(selector).each(function(index, element) {
即使我将它附加到正文它也没有工作(