首頁(yè)  >  篩選  > end()

返回值:jQueryend()

V1.0jQuery end() 方法概述

回到最近的一個(gè)"破壞性"操作之前。即,將匹配的元素列表變?yōu)榍耙淮蔚臓顟B(tài)。

如果之前沒(méi)有破壞性操作,則返回一個(gè)空集。所謂的"破壞性"就是指任何改變所匹配的jQuery元素的操作。這包括在 Traversing 中任何返回一個(gè)jQuery對(duì)象的函數(shù)--'add', 'andSelf', 'children', 'filter', 'find', 'map', 'next', 'nextAll', 'not', 'parent', 'parents', 'prev', 'prevAll', 'siblings' and 'slice'--再加上 Manipulation 中的 'clone'。

示例

描述:

選取所有的p元素,查找并選取span子元素,然后再回過(guò)來(lái)選取p元素

HTML 代碼:
<p><span>Hello</span>,how are you?</p>
jQuery 代碼:
$("p").find("span").end()
結(jié)果:
[ <p><span>Hello</span> how are you?</p> ]