Questions tagged [jquery-end]

The .end() function in JQuery is used to finish the most recent filtering operation in the chain.

The .end() function in JQuery is used to finish the most recent filtering operation in the chain.

Example

<div class="parent">
  <div></div>
</div>
$(".parent")
  .find("div")
  .text("child")
  .end()
  .css("color", "red")

Result

<div class="parent" style="color:red">
  <div>child</div>
</div>
5 questions
2
votes
2 answers

jQuery .end method not working with jQuery object

I have a custom plugin very simple. If it returns this after calling it, .end() works great. However if it returns $(this), .end() doesn't work. Why does that happen? Am I missing something here? Code: $.fn.fnBar = function() { …
Diego
  • 16,436
  • 26
  • 84
  • 136
1
vote
1 answer

Behaviour of .end() when used with .before()

When having called .before on elements that are detached from the DOM, .end behaves differently than it does with attached elements: var $div1 = $("div"); console.log($div1.after("foo").end()); //…
pimvdb
  • 151,816
  • 78
  • 307
  • 352
0
votes
1 answer

jQuery's .end() doesn't work as expected after .contents()?

a = $("table").clone().find("p:has(input)").contents().not("span:has(input:checked)").remove().end().text() b = $("table").clone().find("p:has(input)").contents().not("span:has(input:checked)").text() c =…
hobbes3
  • 28,078
  • 24
  • 87
  • 116
0
votes
1 answer

jQuery end(), where exactly it is useful

I have looked in to the jquery documentation of function end(), definition : End the most recent filtering operation in the current chain and return the set of matched elements to its previous state. i have understood the functionality, but i could…
RONE
  • 5,415
  • 9
  • 42
  • 71
0
votes
1 answer

Jquery end() method

I have a html file like this:
  • list