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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:04:59+00:00 2026-05-31T23:04:59+00:00

The following markup is exaggerated to demonstrate the problem. I’m trying to capture the

  • 0

The following markup is exaggerated to demonstrate the problem.

I’m trying to capture the main row of a clicked link…it just so happens that its buried deep within a bunch of other things.

<div class="mainRow">
...
</div>
<div class="mainRow">
    <div>
        <div>
            <div>(x number of layers)
                <div>
                    <div>
                        <div>
                            <div>
                                <div>
                                    <div>
                                        <a class="someLink">click me</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>(/x number of layers)
        </div>
    </div>
</div>
<div class="mainRow">
...
</div>

In mootools *, you can manually get that parent element by saying .getParent().getParent()...<xTimes>...getParent() etc

Is there a way to arbitrarily traverse up a chain of parents x number of times so that it stops at div.mainRow ?

(Edit: lol… sorry everyone, i guess i wrote “jquery” in my question by mistake. i am asking about mootools.)

  • 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-31T23:05:00+00:00Added an answer on May 31, 2026 at 11:05 pm

    parent traversal is simple in mootools.

    in your case, the getParent([optional selector]) method will try to match any parent node:
    http://mootools.net/docs/core/Element/Element#Element:getParent – so .getParent("div.mainrow") will return the first match or null – if none found.

    you can also use a reverse combinator selector at times, though not on a click event, probably.

    eg, document.getElements("div.mainRow a.someLink ! div.mainRow") will return only the div.mainRow elements that have a link with class “someLink” directly. in a way, like .contains() but you can return the parent of the a as well just by appending ! div

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

Sidebar

Related Questions

I have the following markup that is used to produce a pop-up style mega-menu
Consider the following markup: <!DOCTYPE html> <html> <head> <title>Test Page</title> <link href=screen.css rel=stylesheet />
I have the following markup which is just a small portion of the total
Say I have the following markup: <li><a href="somehwere">Link text</a></li> If I have a background
I have the following markup that will be repeated for several questions <p id=questionOne>What
I have the following markup on page load: <select name=sel_billing_address></select> After page load that
I have the following markup. <para><span class=bidi/><span class=ind/>1</para> I'm trying to achieve this... <para><span
I have the following markup, <ul id=menu> <li><a href=#>Something1</a></li> <li><a href=#>Something2</a></li> <li><a href=#>Something3</a></li> <li><a
I have the following markup: <div id=routes> <ul id=routesList> <li class=routes>Route 1</li> <li class=routes>Route
i'm having the following markup using 2 divs. the #child div has set position:absolute;

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.