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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:55:32+00:00 2026-06-15T18:55:32+00:00

I have the following: a = li.parent().parent().children(‘a, span’); I have a loop set up

  • 0

I have the following:

a = li.parent().parent().children('a, span');

I have a loop set up which starts with a link and goes up the chain.
If I understand this correctly then the code above selects a link if there is a span
following it. Therefore it correctly selects:

   <a ..>..<span>History</span> .. </a> and
   <a ..>..<span>Overview</span> .. </a>

However I do not want it to select:

   <a ..> ..<span class="toggle"></span>

From the following HTML:

<ul id="menu" class="arbo with-title">
   <li>
      <a class="title-a">
         <span>Overview</span></a>
      <ul>
         <li>
            <span class="toggle"></span>
            <a class="folder"><span>Background</span></a>
            <ul>
               <li><a data-href="/History" class="document-web"><span>History</span></a></li>
               <li><a data-href="/eatures" class="document-web"><span>Features</span></a></li>
               <li><a data-href="/Design-Goals" class="document-web"><span>Design Goals</span></a></li>
            </ul>
         </li>
         <li>

Is there a way that I can make the select at the top of this question not
notice a span with the class of toggle? Something like:

a = li.parent().parent().children('a, span(only if the element does not have a class of togggle)');

FYI here’s the loop code:

function populateBreadcrumb(a: JQuery, $breadcrumb: JQuery) {
  while (a.length > 0) {
     $breadcrumb.prepend('<li><a >'+a.html()+'</a></li>');
     var li = a.parent();
     a = li.parent().parent().children('a, span');
  }
}
  • 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-15T18:55:33+00:00Added an answer on June 15, 2026 at 6:55 pm

    You can do this with the :not selector:

    a = li.parent().parent().children("a, span:not(.toggle)");
    

    This should do the trick.

    Though you might want to use find instead of children to get all spans:

    $("#menu").find("a, span:not(.toggle)");
    

    jsfiddle: http://jsfiddle.net/mGv6N/

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

Sidebar

Related Questions

I am using JavaScript with jQuery. I have the following var $ticket = $nxt.parent().prev().children('.ticket');
I currently have the following series of JQuery selectors: $(this).parent().parent().children('a').children('img').attr('src') It works just fine
I have the following code: foreach (var parent in parents) { var children =
I have following class that defines attached property to set children's margin: public class
I have the following line bound to a click event: $(this).parents(.addonoptions).children().removeClass(highlight); It should strip
I have an odd linq subquery issue. Given the following data structure: Parents Children
Say I have the following code: class Parent { static string MyField = ParentField;
I have the following two models: class Parent < ActiveRecord::Base has_one :child, dependent: :destroy
Suppose we have the following table data: ID parent stage submitted 1 1 1
I have the following sample of data to insert into tables(from parent to child,

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.