amitabhaghosh197
11/30/2015 - 5:21 AM

jQuery end defined

jQuery end defined

reff: http://stackoverflow.com/questions/1745814/what-does-the-end-function-do-in-jquery

Working fiddle: https://jsfiddle.net/amitabhaghosh197/w2wde7gr/

Basically,

.end()

tells it to go back to body after finding all spans, and apply the border to body, not the spans.

BODY > SPAN > APPLY BORDER TO SPANS

with end() it becomes

BODY > SPAN > GO BACK TO BODY > APPLY BORDER TO BODY

$('body').find('p').end().css({'border':'1px solid red'});