这两天照着jQuery1.2 API 中文版学习jQuery。今天看到empty和remove这里,发现有一个小小的问题。
在讲到empty和remove的时候,有一个地方可能混淆了,对于,remove方法,API中写道:从DOM中删除所有匹配的元素。这个方法不会把匹配的元素从jQuery对象中删除,因而可以在将来再使用这些匹配的元素。查阅jQuery官网API(http://api.jquery.com/remove/),会发现对于remove方法的描述是
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.
remove方法会从DOM中移除它自身,以及它的子元素,中文版本的API中对于remove方法的描述应该是错误的,它应该是对empty方法的描述。empty方法会移除当前元素内部的所有东西,包括文本,但是,它会保留当前元素,将来还可以使用。
希望和我一样使用这一版本的API学习jQuery的朋友不会在这个地方弄迷糊了。