You need to declare a variable outside of both functions, in the area that they can access. I suggest combining your two document handlers into one function and declaring a variable here:
$(function() { var var1;
Or you can make the variable global if you need to access it from other places.
Please note that the events of two clicks have nothing in common with each other, so they, of course, do not use the event data. In addition, clicking on the second anchor can occur before clicking on the first, so you can specify var1 as the default and / or test for undefined to use it in the second click handler.
(I also changed var1 to var1 because the JS convention should start the variable names with a lowercase letter - you don't have to follow the convention, but I would recommend it.)
nnnnnn
source share