Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7398425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:52:05+00:00 2026-05-29T03:52:05+00:00

i go to the site http://api.jquery.com/end/ just to understand how end() use and how

  • 0

i go to the site http://api.jquery.com/end/ just to understand how end() use and how it works. unfortunately i just do not understand what it does. so i need to know in what kind of situation end() should be used.

here is small example

<ul class="first">
  <li class="foo">list item 1</li>
  <li>list item 2</li>
  <li class="bar">list item 3</li>
</ul>
<ul class="second">
  <li class="foo">list item 1</li>
  <li>list item 2</li>
  <li class="bar">list item 3</li>
</ul>

 $('ul.first')
         .find('.foo')
         .css('background-color', 'red')
         .end()
         .find('.bar')
         .css('background-color', 'green');

i just do not understand what kind of role end() function play here.

it would be great if someone help me to understand the usage of end() function with small & easy sample code. please help. thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T03:52:06+00:00Added an answer on May 29, 2026 at 3:52 am

    This is explained pretty well in the documentation:

    End the most recent filtering operation in the current chain and return the set of matched elements to its previous state.

    It’s clearer if I render the code like so:

    $('ul.first')
        .find('.foo')
           .css('background-color', 'red')
        .end()
        .find('.bar')
           .css('background-color', 'green');
    

    It means that what you’re setting background-color to green on is ul.first .bar, not ul.first .foo .bar. It undoes the .find('foo') filter in that call chain.

    An equivalent would be:

    $('ul.first').find('.foo').css('background-color', 'red');
    $('ul.first').find('.bar').css('background-color', 'green');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following function works perfectly on our production site function flickrGetPhotos(){ $.getJSON(http://api.flickr.com/services/rest/?method=flickr.photosets.getList&api_key= + flickrApiKey
here is the site : http://www.notrepanorama.com at the bottom left, i use a jquery
I need same menu like on this site http://www.salesforce.com/aloha.jsp in wordpress theme. Multilevel dropdown
Started looking at the win32 API on this site: http://www.winprog.org/tutorial/start.html I've literally just compiled
I am using a jQuery Multi-Friend Selector form this site; http://mike.brevoort.com/2010/08/10/introducing-the-jquery-facebook-multi-friend-selector-plugin/ And it works
I recently deployed a site http://boardlite.com . One of the tester websites http://www.gidnetwork.com/tools/gzip-test.php suggests
for this site: http://yoursdproperty.com/ do you see how there some extra white space all
like in this site: http://www.1stwebdesigner.com/resources/57-free-image-gallery-slideshow-and-lightbox-solutions/ it only loads the image when you are rally
My suckefish menu on site http://www.lendorlaw.com cut off the right side of my menu.
I have a simple web site ( http://www.kousenit.com/twitterfollowervalue ) that computes a quantity based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.