确定最后点击的项目 [英] Determine last item clicked

查看:60
本文介绍了确定最后点击的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从其中的模糊事件中检索引起聚焦(模糊)事件的DOM元素.以下代码将为我提供失去焦点的元素的ID,而不是导致元素失去焦点的元素的ID.这是我需要的第二个要素.

I need to retrieve the DOM element that causes a focusout (blur) event from WITHIN the blur event. The following code will give me the ID of the element that lost focus, NOT the element that caused the element to lose focus. It is that second element that I need.

.live('blur', function(e) {
    var id = $(this).attr('id');
}

如何获取导致模糊的元素,而不是模糊所附加的元素?我能想到的唯一方法是捕获window.click事件,然后在那里处理所需的逻辑,但这会变得棘手,所以我希望有一种方法可以从blur事件中获取DOM元素.

How do I get the element that caused the blur, not the element the blur is attached to? The only way I can think of is to capture the window.click event and then handle the logic I need there, but that will get tricky so I am hoping there is a way to get the DOM element from within the blur event.

推荐答案

与此:

$(document).click(function(event) {
   window.lastElementClicked = event.target;
});

欢呼

这篇关于确定最后点击的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆