jquery end() method


  Translation results:

end

英[end] 美[ɛnd]

n.End;<positive>result;termination;last part

vt.& vi.End, terminate

jquery end() methodsyntax

Function: end() method ends the most recent filtering operation in the current chain and restores the set of matching elements to its previous state.

Syntax: .end()

Description: Most jQuery traversal methods will operate on a jQuery object instance and generate A new object that matches a different set of DOM elements. When this happens, the new set of elements should be pushed onto the stack maintained in the object. Each successful filter method call pushes a new element onto the stack. If we need the old set of elements, we can use end() to pop the new set from the stack.

jquery end() methodexample

<!DOCTYPE html>
<html>
<head>
  <style>p { margin:10px; padding:10px; }</style>
  <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
</head>

<body>
  <p><span>Hello</span>, how are you?</p>
  <script>$("p").find("span").end().css("border", "2px red solid");</script>
</body>
</html>
Run instance »

Click the "Run instance" button to view the online instance

Popular Recommendations

Home

Videos

Q&A