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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:20:27+00:00 2026-05-26T21:20:27+00:00

This works… var start = $(‘.nodes:first>span>div’); var foo1 = $(.nodes:first>span>div>div>div>div>span>div); var foo2 = $(.nodes:first>span>div>div>div>div>span>div>div>div>div>span>div);

  • 0

This works…

    var start = $('.nodes:first>span>div');
    var foo1 = $(".nodes:first>span>div>div>div>div>span>div");
    var foo2 = $(".nodes:first>span>div>div>div>div>span>div>div>div>div>span>div");
    var foo3 = $(".nodes:first>span>div>div>div>div>span>div>div>div>div>span>div>div>div>div>span>div");
    var foo4 = etc,etc...

Trying to consolidate to something like this…

    var start = $('.nodes:first>span>div');
    var separator = ">div>div>div>span>div";
    var foo1 = $("start + 1*separator");
    var foo2 = $("start + 2*separator");
    var foo3 = $("start + 3*separator");
    var foo4 = etc,etc...

Have been muddling for hours, but the syntax for this escapes me! Any pointers? 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-26T21:20:27+00:00Added an answer on May 26, 2026 at 9:20 pm

    Selectors are just strings so you just add strings to together and use them as a selector.

    var start = '.nodes:first>span>div';
    var separator = ">div>div>div>span>div";
    var foo1 = $(start + separator);
    var foo2 = $(start + separator + separator);
    var foo3 = $(start + separator + separator + separator);
    

    Though, if we understood what you were trying to accomplish, there is probably a much nicer way of doing it using less complication. For example, you should probably be using classes on the different types of divs and spans and then target specific classes without regard for how many intervening layers of divs there are. This makes your code much, much less brittle and much less tied to the exact HTML implementation (it still has some dependencies, but not near as many).

    FYI, as far as I know, you can’t multiply strings to get multiple copies of them so 2*str doesn’t get you a string with two consecutive copies of str in it.

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

Sidebar

Related Questions

This works: <html> <body> <div id=bla></div> <script type=text/javascript> var mybla = document.getElementById('bla') </script> </body>
This works: class ButtonCountObserver { private var cnt = 0 // private field def
This works: var.replace(/[^0-9]+/g, ''); That simple snippet will replace anything that is not a
This works : alert(document.getElementById(Container).nodeName); But this doesnt : var CurParent = document.getElementById(Container); alert(CurParent.nodeName); I
This works: var a:BitmapData = new BitmapData(640,480); var b:Bitmap = new Bitmap(a); a.draw(movieClip); This
This works ( .hover ): $('a.directory:not(.trashContent), a.file:not(.trashContent)').hover(function() { if (!dragged) $(this).find('a.suppr:first').show(); }, function() {
This works in all browsers: for (var i in navigator) { console.log(i, ':', navigator[i]);
This works: var r=xS; var regex = new RegExp(r); // Anchor at the end
This works in Firefox/Safari but not on IE var h = parseInt($('#elementWhichHeightCanChange').css('height')); alert(h); on
This works fine: var expectedType = typeof(string); object value = ...; if (value.GetType().IsAssignableFrom(expectedType)) {

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.