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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:37:18+00:00 2026-06-06T01:37:18+00:00

my main file is <div id=man> //some content <div id=one> //some content <div id=two>

  • 0

my main file is

<div id="man">
//some content
<div id="one">
//some content
<div id="two">
//some content
<div id="three">
//some content
<div id="four">
<a title="to delete">delete</a>
<a title="to reset">reset</a>
<a title="to change">change</a>
</div>...// all div ends...


<div id="woman">
//some content
<div id="one">
//some content
<div id="two">
//some content
<div id="three">
//some content
<div id="four">
<a title="to delete">delete</a>
<a title="to reset">reset</a>
<a title="to change">change</a>
</div>...// all div ends...

and the jquery is –

$("document").ready(function(){
$("a:contains(delete)").click(function(){
alert($(this).parent().parent().parent().parent().parent().attr("id"))
})
})

is there any another way to find the top parent instead of using this…??

  • 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-06T01:37:19+00:00Added an answer on June 6, 2026 at 1:37 am

    If you can modify your html slightly and give those top-level divs a common class:

    <div id="man" class="top">
    ...
    <div id="woman" class="top">
    

    …then you can use the .closest() method to select them:

    $("a:contains(delete)").click(function(){
       alert($(this).closest('div.top').attr("id"))
    })
    

    Note that your current html markup is invalid because you are not supposed to give the same id to more than one element. (So given that you should change your markup to fix that it will be no problem to also add a class to the top-level divs.)

    EDIT: Demonstration that the above works even when “man” and “woman” aren’t at the top level: http://jsfiddle.net/NVQXq/

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

Sidebar

Related Questions

Hi everyone in my main html file, I have this div that some img
a HTML file: <html> <body> <div class=main> <p id=tID>content</p> </div> </body> </html> i has
on master file got ... <div id=nav-main> <asp:Menu ID=Menu1 runat=server DataSourceID=SiteMapDataSource1 Orientation=Horizontal Width=573px CssClass=menu-main
My main HTML file dynamically loads in content with; <html> <head> <script src=http://code.jquery.com/jquery-1.7.1.min.js></script> </head>
I write two file main.php and download.php . main.php echo<form action='download.php' method='post'> for(i =
html file: <div id =main> </div> Javascript: //create a div var divElem = $('<div
I'm working on a div (parent) that has two other divs (menu and content)
I have a html file has the general design (some div's) and I need
OK, I am trying to get the title from the file: main.txt, but it's
I am currently building a small website where the content of the main div

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.