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 8863599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:01:11+00:00 2026-06-14T16:01:11+00:00

I have a parent element with multiple children each which require different changes. There’s

  • 0

I have a parent element with multiple children each which require different changes. There’s an easy solution, but I’m wondering whether chaining is possible and would be more efficient.

A very simple example:

<div id="parent">
    <div class="one">One</div>
    <div class="two">Two</div>
    <div class="three">Three</div>
</div>

----------------------

$('#parent .one').text('Some');
$('#parent .two').text('Thing');
$('#parent .three').text('Else');

Is there a way to do something similar to this?

$('#parent')
  .children('.one').text('Some')
  .children('.two').text('Thing')
  .children('.three').text('Else');

Where each child resets the chain back to the parent. Also, would this be efficient other than making the code easier to read? Remember, this is a very simple example to clarify the question. I’m not referring to this exact code. I really appreciate the 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-06-14T16:01:16+00:00Added an answer on June 14, 2026 at 4:01 pm

    end() will return the chain to what it was before the last filtering :

    $('#parent')
      .children('.one').text('Some').end()
      .children('.two').text('Thing').end()
      .children('.three').text('Else');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If you have Parent has_many :children Child Is there any reason a foreign key
I am trying to add an XML node to multiple parent nodes(which have same
is there a way to select with css, elements which have the index multiple
I have multiple dropdowns that each call the following function (passing different arguments) If
I know I can have 1 parent element and 1 child element in my
I have have a 2 div element. One is child and one is parent
I have a parent component, say P, which has function, say Pfunc. I also
I have a superclass called DataItem and it has multiple children and the children
I have a view called DashboardView that instantiates multiple WidgetView s. Each widget needs
I have a question on multiple sections headers at different sections. I have the

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.