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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:56:51+00:00 2026-05-31T06:56:51+00:00

Below is my code fragment: <div onclick = myClick(‘value 1’)> button 1 </div> <div

  • 0

Below is my code fragment:

<div onclick = "myClick('value 1')">
    button 1
</div>
 <div onclick = "myClick('value 2')">
    button 2
</div>

Basically when I for each click on a different div, a different value will be passed to the JavaScript function.

My Question is how can I keep track of the value passed in the previous click?

For example, I click “button 1”, and “value 1” will be passed to the function. Later, I click on “button 2”, I want to be able to know whether I have clicked “button 1” before and get “value 1”.

  • 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-31T06:56:52+00:00Added an answer on May 31, 2026 at 6:56 am

    You can define somekind of variable, like var lastUsed;
    add additional line to your function:

    var lastUsed = null;
    function myClick(value){
      prevClicked = lastUsed; //get the last saved value
      ...
      lastUsed = value; //update the saved value to the new value
      ...
    }
    

    And here you go

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

Sidebar

Related Questions

Below code makes form to be submitted without html5 validation... $j(document).on(click, #client_entry_add, function(event){ ajax_submit();});
Simple code fragment below draws an ellipse on a VB.NET panel. I now need
For the C++ code fragment below: class Foo { int a[]; // no error
XSLT newbie question: Please fill in the blank in the C# code fragment below:
The code fragment I am to analyse is below: int sum = 0; for
Please see the code fragment below, specifically the first 'else if' statement. I want
Please see the C++ code fragment below: #include ..... Class1 class1; Class2 class2; ...
I'm resizing jpegs by using the Graphics.DrawImage method (see code fragment below). Can anyone
In the code fragment below, the array deck should equal [6,9,5,6,5,1,2] since Ruby passes
I wish to display image using c++ OpenCV code. Below are the code fragment:

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.