我使用jquery 1.3.2。我创建了一个指向图像的变量。我想在同一个位置复制这个图像。
在代码中我使用了选择器http://jsfiddle.net/Z7Pry/101/
var image = closestwrap.find('img');
$(image).clone().prependTo("#contentWrapRight")
但我需要使用变量“image”才能在同一位置匹配和复制完全确定的图像。这不起作用
$(image).clone().prependTo(image)
我应该怎么做才能实现此功能?谢谢。
答案 0 :(得分:0)
要提供正确的起始位置,请将呼叫更改为css
:
$(image).clone().prependTo("#contentWrapRight").css({
'position': 'fixed',
left: productX, top: productY, 'z-index': '999'
的 Demonstration 强>
请注意,您可以将所有$(image)
更改为image
,因为image
已经是jQuery对象。
答案 1 :(得分:0)
而不是prependTo
使用insertBefore()
或insertAfter()
。
$(image).clone().insertBefore(image);
请参阅http://jsfiddle.net/gaby/Z7Pry/102/
使用productX
和productY
作为初始位置,basketX
和basketY
作为动画的最终位置。