some div

Where is the jQuery data method information located?

Can i do

<div class="some_div">some div</div>
<script>
    jQuery('.some_div').data('some_data','some info').remove();
</script>

where is the information added by the data method still around the DOM? Do I need to uninitialize? Is the information automatically deleted when the div element has no links?

+3
source share
2 answers

Data is stored in a variable accessible to jQuery objects through closure. It is never saved in dom. The delete method deletes data along with the DOM element.

.remove ([selector])

.empty(),.remove()   DOM. .remove(), , . , jQuery, .

source: jQuery API: remove()

+4

jQuery DOM .

: jQuery1278101043588: 1

, . .

, , .remove() .empty().

DOM , .detach().

jQuery .removeData() , . (), .

+4

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


All Articles