Reputation: 1425
Hey, hope someone can help with this..
How can I get the previous ID of a clicked div element using jQuery?
Is this even possible?
e.g. I have two div's named div1 and div2, I click on div1 then on div2, how can I get the ID of div1?
Many thanks
Upvotes: 1
Views: 163
Reputation: 42948
Store it in a variable.
var lastClicked = null;
$("div").click(function() {
if (lastClicked) {
// use lastClicked here
}
// Do current click stuff
lastClicked = this;
});
Upvotes: 10