detach()和remove()的区别?
小白
小白 2016-12-19 17:29:29
0
2
1047
var p = $("p:first").remove();
p.css('color','red').text('p1通过remove处理后,点击该元素,事件丢失')
$("body").append(p);

以上代码,p首先被移除掉了,自身元素p标签也应该将移除了,可是为什么p又重新设置样式及内容的时候却还是会是p标签呢

小白
小白

好好学习,天天向上!!!

reply all(2)
数据分析师

What is the difference between detach() and remove()? -PHP Chinese website Q&A-What is the difference between detach() and remove()? -PHP Chinese website Q&A

Please watch and learn.

迷茫

这个方法不会把匹配的元素从jQuery对象中删除,因而可以在将来再使用这些匹配的元素。但除了这个元素本身得以保留之外,其他的比如绑定的事件,附加的数据等都会被移除

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!