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

The Archive Base Latest Questions

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

Given the html: <div class=a> <div class=b> <div class=c> <div class=d> </div> </div> <div

  • 0

Given the html:

     <div class="a">
        <div class="b">
           <div class="c">
             <div class="d">
             </div>
           </div>
          <div class="d">
          </div>
        </div>
     </div>

Im interested in the selecting the parent element with class a applied to it when any element with the class ‘d’ is clicked.

I have the following javascript / jQuery, but it seems very messy. Is there a neater way?

<script>
   $('.d').click(function(){
      var elementA =  $(this).parentsUntil('.a').last().parent();    
   })
</script>
  • 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-26T05:27:42+00:00Added an answer on May 26, 2026 at 5:27 am

    You want $(this).closest('.a').

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

Sidebar

Related Questions

Given this HTML: <div class=OpenIDSelector>some text</div> Why does this JQuery selector match it on
Newbie question. Given the following html. <div id=mycontainer1 class=container> <input type=text class=name/> <input type=text
In my html i have got div with given class. After clicking a button
Two jQuery questions: 1) Given this HTML structure <div id=tipper class=tiplink><a href='test.html' >Link Text</a>
Given the following HTML: <div class=component> <div class=component> <div class=component> </div> </div> <div class=component>
Given the following HTML snippet: <div class=image> <div class=placeholder> <a class=load iframe href=https://contestapp.com/images/4><img src=/uploads/image/image_file/4/thumb_he_sport_nutrition_for_active_kids_photo.jpg?1307271623
Given the following HTML on a page: <div class='test'> <p><span id='id1' class='test1 test2 test3'>test
Given the following HTML: <body><div class=container></div></body> and CSS: body { background-color: #e9f9e9; } .container
Given this html: <div class=nation> <a href=library.php?type=nation&amp;id=America> <div class=nation-image> <img src=nations/America.png alt=snip /> </div>
given the html: <div class=ships> <div class=ship header> </div> <div class=ship> <div class=image> <img

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.