Working with Selections | jQuery Learning Center

PHOTO EMBED

Sat May 29 2021 01:11:16 GMT+0000 (UTC)

Saved by @ejiwen

$( "#content" )
    .find( "h3" )
    .eq( 2 )
        .html( "new text for the third h3!" )
        .end() // Restores the selection to all h3s in #content
    .eq( 0 )
        .html( "new text for the first h3!" );
content_copyCOPY

jQuery also provides the .end() method to get back to the original selection should you change the selection in the middle of a chain:

https://learn.jquery.com/using-jquery-core/working-with-selections/