jQuery数据的方法信息在哪里? [英] Where does jQuery data's method information go?

查看:75
本文介绍了jQuery数据的方法信息在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以吗

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

其中信息是用数据的方法添加的,还是在DOM周围?我需要取消初始化吗?当div元素没有引用时,是否会自动删除信息?

where the information is added with data's method, is still around the DOM? Do I need to uninitialize? Is the information automatically removed when the div element has no references left?

推荐答案

数据存储在jQuery可用的变量中对象通过关闭。 永远不会存储在dom中。删除方法会删除数据以及DOM元素。

The data is stored in a variable available to the jQuery objects via closure. It is never stored in the dom. Remove method deletes the data along with the DOM element.


.remove([selector])

与.empty()类似,.remove()
方法从DOM中取出元素。
我们使用.remove()当我们想要
删除元素本身,以及
里面的所有东西。 除了
元素本身,所有绑定
事件和与
相关联的jQuery数据元素都被删除

Similar to .empty(), the .remove() method takes elements out of the DOM. We use .remove() when we want to remove the element itself, as well as everything inside it. In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed.

来源:jQuery API:删除()

source: jQuery API: remove()

这篇关于jQuery数据的方法信息在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆