What is the functional difference between these three jQuery methods:

  • 分离()
  • hide()
  • remove()

推荐答案

hide()将匹配元素的CSS display属性设置为none.

remove() removes the matched elements from the DOM completely.

detach()类似于remove(),但保留与匹配元素关联的存储数据和事件.

To re-insert a detached element into the DOM, simply insert the returned jQuery set from detach():

var span = $('span').detach();

...

span.appendTo('body');

Jquery相关问答推荐

jQuery在点击函数后获取
  • 元素的id/value
  • 如何从 jQuery 转到 React.js?

    在 JSON 对象上使用 jQuery 的 find()

    如何使用 jQuery 的 getJSON() 方法传递请求标头?

    如何使用 jQuery go 除 HTML 标签?

    对混合的字母/数字数组进行排序

    使用 jQuery 将行添加到表的 tbody

    页面滚动后,jQuery可拖动在错误的位置显示助手

    jQuery 序列化不注册复选框

    即使通过Javascript代码判断,如何触发复选框单击事件?

    验证外部脚本是否已加载

    jQuery.extend 和 jQuery.fn.extend 的区别?

    页面重新加载后,如何使用 twitter bootstrap 保持当前选项卡处于活动状态?

    JQuery Ajax Post 导致 500 内部服务器错误

    禁用 jquery Select 的下拉菜单

    如何使用 javascript 展开和折叠

    如何使用 jQuery 检测 IE 8?

    .animate() 的回调被调用两次 jquery

    是否可以将 async:false 设置为 $.getJSON 调用

    如何使用 jQuery 处理复选框的更改?