首頁  >  篩選  > end()

返回值:jQuery end()

V1.0 概述

回到最近的一個"破壞性"操作之前。即,將匹配的元素列表變為前一次的狀態。

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

示例

描述:

選取所有的p元素,查詢並選取span子元素,然後再回過來選取p元素

HTML 程式碼:

<p><span>Hello</span>,how are you?</p>
jQuery 程式碼:

$("p").find("span").end()
結果:

[ <p><span>Hello</span> how are you?</p> ]