开发者

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;
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜