jQuery get lasted clicked on element...?
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
Store it in a variable.
var lastClicked = null;
$("div").click(function() {
if (lastClicked) {
// use lastClicked here
}
// Do current click stuff
lastClicked = this;
});
精彩评论