0

我使用 jquery 1.3.2。我创建了一个指向图像的变量。我想在同一位置复制此图像。

在代码中我使用选择器http://jsfiddle.net/Z7Pry/101/

var image = closestwrap.find('img');
$(image).clone().prependTo("#contentWrapRight")

但我需要使用变量“图像”来匹配和复制同一位置上的某个图像。这不起作用

$(image).clone().prependTo(image)

我应该怎么做才能实现这个功能?谢谢你。

4

2 回答 2

0

要给出正确的起始位置,请将调用更改为css

    $(image).clone().prependTo("#contentWrapRight").css({
        'position': 'fixed',
        left: productX, top: productY, 'z-index': '999'

Demonstration

请注意,您可以将所有内容更改$(image)为简单imageimagejQuery 对象。

于 2013-06-09T10:13:08.050 回答
0

而不是prependTo使用insertBefore()or insertAfter()

$(image).clone().insertBefore(image);

http://jsfiddle.net/gaby/Z7Pry/102/


使用productXandproductY作为动画的初始位置,basketXandbasketY作为动画的最终位置。

于 2013-06-09T10:13:49.660 回答