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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:24:51+00:00 2026-05-30T14:24:51+00:00

I have three div’s… <div id=1></div> <div id=2></div> <div id=3></div> When I click on

  • 0

I have three div’s…

<div id="1"></div>
<div id="2"></div>
<div id="3"></div>

When I click on a random div, it moves the order of the div to the top (Let’s use ID #2 for example). So the div’s could be out of chronological order after this point. Example below…

<div id="2"></div>
<div id="1"></div>
<div id="3"></div>

So if this is the case, is there a way to get the last div ID I clicked?

  • 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-30T14:24:53+00:00Added an answer on May 30, 2026 at 2:24 pm

    Do you mean this?

    var lastID;
    
    // document.ready
    $(function() {
        $("div").on("click", function() {
            lastID = $(this).attr("id");
        });
    });
    
    function something() {
        // lastID is the id of the last div clicked.
    }
    

    Declaring lastID outside the document.ready function means it’s globally accessible, so you can use it in other functions later.

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

Sidebar

Related Questions

Let's say I have three <div> elements on a page. How can I swap
I have three unordered list each surrounded by a container div (An example is
Let's say I have three div elements with classes a , b , and
I have three divs : <div id=login /> <div id=content /> <div id=menu />
i have three divs like that: <div id=1 >id=1</div> <div id=2>id=2</div> <div id=3>id=3</div> Now
I have three DIVs, something like this: <div id=header> ... </div> <div id=content> <div
my site has three div elements, header, content and footer. i have a picture
I am using jquery UI tabs I have three ajax tabs like so: <div
I am new to dojo. I have three divs; the first div has 10
If i have the following markup; <div id=container> <div id=box> <div id='sameHeight'>One<br>two<br>three</div> <div id='sameHeight'>four</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.