Quite simple. I have a blur() event handler that fires a function, I want the function not to fire when the blur is triggered by the click on a certain element.
I tried document.activeElement but i get a HTMLBodyElement instead of the element I click on.
code:
$j(".input_filtrare_camp").blur(
function(event) {
nr_img = this.parentNode.id.split("_")[1];
//alert(document.activeElement);
if(document.activeElement.id.indexOf("img_exact") < 0) //run only if the id of the element I clicked on doesn't contain "img_exact"
enter_input_filtrare(event.target);
});
the alert is for troubleshooting, of course.
I used techfoobar's solution as follows:
var currElem = null;
$(document).mousedown(function(e) {
currElem = e.target;
});
$j(".input_filtrare_camp").blur(
function(event) {
nr_img = this.parentNode.id.split("_")[1];
if(currElem.id.indexOf("img_exact") < 0) //run only if the id of the element I clicked on doesn't contain "img_exact"
enter_input_filtrare(event.target);
});
Check out PointedEars' answer for some important information regarding this issue.