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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:48:38+00:00 2026-05-27T23:48:38+00:00

I am working with a dashboard of divs and each div it has a

  • 0

I am working with a dashboard of divs and each div it has a tree of which the buttons are. Every time I have to know which the id of that div is so I am using parent() alot.

Mostly I am doing $(this).parent().parent().parent() to find the ID of div so I can set variables to it. The app is based on the id’s of each div.

Is it consider slow to use parent() up to 3 times but pretty much on every function?

Is there any other alternative?

I am looking for something like benchmarks-style which shows what’s faster.

Here is an example of the tree:

<div id="6179827893" class="dashdiv">
   <div class="buttons">
     <li><a href="#" class="btn1">Button 1</a></li>
     <li><a href="#" class="btn2">Button 2</a></li>
     <li><a href="#" class="btn3">Button 3</a></li>
     <li><a href="#" class="btn4">Button 4</a></li>
     <li><a href="#" class="btn5">Button 5</a></li>
     <li><a href="#" class="btn6">Button 6</a></li>
   </div>
   <div class="dashcontent">

    ....

   </div>
</div>
  • 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-27T23:48:38+00:00Added an answer on May 27, 2026 at 11:48 pm

    You’ve got a few options to achieve the same effect.

    Benchmark: http://jsperf.com/parents-method. According to this benchmark, my method is roughly 100x faster than your method.

    Method (see below) : Operations per second (higher is better)
    parentNode3x       : 4447k
    $(parentNode3x)    :  204K
    $().closest        :   35k
    $().parents        :    9k
    $().parent()3x     :   44k
    
    // Likely the fastest way, because no overhead of jQuery is involved.
    var id = this.parentNode.parentNode.parentNode.id;
    
    // Alternative methods to select the 3rd parent:
    $(this.parentNode.parentNode.parentNode) // Native DOM, wrapped in jQuery
    
    // Slowpokes
    $(this).closest('.dashdiv')              // Hmm.
    $(this).parents('.dashdiv:first')        // Hmm...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a portal/dashboard type interface which has panels/widgets that can be freely
I'm working on a kind of dashboard mini site that has blocks with a
I have developed a web dashboard which has a structure of controls embedded inside
I am working on a small web dashboard -project that has backend implemented with
I'm working on a type of dashboard that contains div's of various sizes. The
My company has been working on a Flex dashboard that displays realtime financial information.
I'm working on dashboard application where I have to retrieve a set of records
I am working on a dashboard which displays loads of graphs, tables and other
I am working on a dashboard project where the art director wishes to have
I'm working on creating a dashboard. I have started to refactor the application so

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.