JQuery animation error for cloned elements

This works fine in Firefox, but Safari, Opera and Chrome have problems. The error will be thrown by jQuery.ui (line 3181), which controls the color change of elements, that is, the "Highlight" effect.

This only happens when trying to clone and select a clone in the same action, i.e. $(targetStory).after(targetStory.clone().effect("highlight", {}, 1300));

This works fine in Firefox, but causes other browsers to stop - targetStory

it's just the id of the cloned element and needs to be cloned after that element.

Has anyone encountered this error before and is there any other solution to animate the clone easily? The fewer lines the better.

0


a source to share


2 answers


What about:

 $(targetStory).clone().effect("highlight", {}, 1300)).insertAfter(targetStory);

      



Exact thing, just a different order. Not sure why FF is ok and the others are broken though ...

0


a source


If the element you are cloning to has an ID, you need to remove (or change) the clone ID before putting it back into the DOM. Try:



$(targetStory).clone().removeAttr('id').insertAfter(targetStory)
  .effect(...);

      

0


a source







All Articles