Is it possible to prevent auto removal of JQuery data when removing the element from the DOM?
When i for example set some data on a JQuery object for example:
The .detach() method is the same as .remove(), except that .detach() keeps all jQuery data associated with the removed elements. This method is useful when removed elements are to be reinserted into the DOM at a later time.(Taken from here)
var x = $("#x").data("name", "assassinbeast"); x.detach() console.log(x.data('name'))
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="x" data-name="dsdsdsdsd">Element</div>