Identifying lastclick in JavaScript

I need to get the last click arguments.

My JavaScript code:

 <a href="#" onclick="show(fid1,1);">Link1</a>
 <a href="#" onclick="show(fid2,2);">Link2</a>
 <a href="#" onclick="show(fid3,2);">Link3</a>

Now I need another JavaScript function that finds out the last click of show function's arguments. How can I do it?

function LastclickId(){


If I understand your question correctly, you want to keep track of the most-recent arguments to show(), right? If that's indeed what you want to do, you could add two variables to your global namespace and just assign the values whenever you call show():

last_foo = 0; // Global namespace
last_bar = 0;

function show(foo, bar) {
    last_foo = foo;
    last_bar = bar;


Then in any function on that page, you can get the values from last_foo and last_bar.

If you don't like to have global variables around, you can wrap your related methods into a single object:

var yourObject = function () {

  // private members...
  var lastClicked;

  function setLastClicked(id, n) {
    lastClicked = id + "," + n

  return {

      // public members...
      show: function (foo, bar) {
          // ....
          setLastClicked(foo, bar);

      getLastClicked: function(){


Set a global variable in the show function. Then read it in the lastClickID function.

Need Your Help

How to get XDebug working on Mac command line PHP

php osx xdebug zend-server-ce

I recently installed Zend Server Community Edition on a Mac with Snow Leopard. I can't get XDebug to work ... it shows up in the output for phpinfo from a web browser, but when I var_dump() a varia...

Marmalade SDK Widget

android sdk widget marmalade

I'm using Marmalade SDK and I want to create an app widget. I wrote this in pure Android and now I have a problem: how to attach it to my Marmalade project? I have access to AndroidManifest.xml and...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.