嘿,希望有人可以帮忙解决这个问题..
如何使用jQuery获取单击的div元素的先前ID?
这甚至可能吗?
例如,我有两个div命名为div1和div2,我点击div1然后在div2上,我如何获得div1的ID?
非常感谢
Jes*_*ess 10
将其存储在变量中.
var lastClicked = null;
$("div").click(function() {
if (lastClicked) {
// use lastClicked here
}
// Do current click stuff
lastClicked = this;
});
Run Code Online (Sandbox Code Playgroud)