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

  • Home
  • SEARCH
  • 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 8368443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:23:27+00:00 2026-06-09T13:23:27+00:00

Ok guys, as promised, here is the real deal, first the sample html: <li

  • 0

Ok guys, as promised, here is the real deal, first the sample html:

<li data-foo="bar">
    <span id="a"></span>
    <ul>
        <li>
            <span id="1"></span>
            <ul>
                <li>
                    <span id="b"></span>
                </li>
            </ul>   
        </li>

        <li>
            <span id="2"></span>
            <ul>
                <li>
                    <span id="c"></span>
                </li>
            </ul>   
        </li>

    </ul>

</li>

<li data-foo="bar">
    <span id="d"></span>
    <ul>
        <li>
            <span id="3"></span>
            <ul>
                <li>
                    <span id="e"></span>
                </li>
            </ul>   
        </li>

        <li>
            <span id="4"></span>
            <ul>
                <li>
                    <span id="f"></span>
                </li>
            </ul>   
        </li>

    </ul>

</li>

I want to get the window to pop up “12”, then pop up “34”… so here is my nested functions attempt:

<script>
    var poptext = "";

    $('li[data-foo=bar]').each(

    function () {

        $(this li span).each(function () {
            poptext = poptext + $(this).attr("id");
        }

        alert(poptext);
        poptext = "";

        );

    }

    );
</script>

This does not seem to be working, I think Jquery might got confused with multiple “this” keywords? Also there could be something wrong with the selector for those spans to begin with.

Thanks guys!

  • 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-09T13:23:29+00:00Added an answer on June 9, 2026 at 1:23 pm

    I think you are looking for the direct descendant selector: >

    Used like this:

    $('li[data-foo=bar]').each(function () {
         var poptext = "";        
         $(this).find('> ul > li > span').each(function () {
             poptext = poptext + $(this).attr("id");
         });
         alert(poptext);
    });
    

    Will only select the nodes that are direct children of the previous expression on the left hand side.

    A more verbose, but maybe readable version could be:

    $(this).children('ul').children('li').children('span') // selects the same 
    

    See it in action here: http://jsfiddle.net/xYgJg/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

guys. I have two view controllers with two uiwebviews. Here is my code: First
Guys i want to get the top 3 disease and also their count from
guys, I want to set actions to touches. If people make single touch -
Guys i am making c# windows application and i want to open any explorer
Guys. I use getpixel & getdata to retrieve data from the same pic.but some
Guys Can you advise good data grid in zend framework expect the zdgrid. I
guys I want to start programing with C++. I have written some programs in
Guys I want create files for check somethings, and create my owner custom rules,
guys, I have the problem when copying database from local assets folder to /data/data/package_name/databases
Guys, this can't be for real I'm trying to make a .NET 2.0 executable

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.