Migrate jQuery () data when an element is destroyed and recreated

Can anyone think of a (preferably quick) way to move data () attached to a DOM element to the newest instance?

The Lightbox plugin that I use removes and reattaches the element to the page to display it in a lightbox (for aviod problems with multiple identifiers that ASP.net has) and, obviously, .data () that is attached to the element is lost when this happens.

+3
source share
1 answer

A relatively new overload for .clone(), which you can use to do this.

.clone(true) will copy an element with events and data without changes.

, .detach(), .remove(), . :

.detach() .remove(), , .detach() jQuery, . , DOM .

+2

Source: https://habr.com/ru/post/1739133/


All Articles