I need to find the element clicked which causes a text input to blur and store it as a variable. how can I determine the id of the element that was clicked to cause the input 'textBox' to lose focus? I don't know if I am approaching this the right way, but this code below is what I have so far. I tried document.activeElement
, but it only worked on inputs and not elements such as li's and anchor tags Thanks
javascript:
var elClicked;
$('textBox').blur(function(){
elClicked = // what is the id of the element that caused blur?
alert(elClicked);
});
html:
<input type = "text" id = "textBox">
<!-- example elements -->
<input type = button id = "element1" />
<a href = "#" id = "element2">text</a>
<ul><li id = "element3">list</li></ul>