I have a page with a textarea #content
and an input textbox #name
. Once the user has clicked on #content
, I want to prevent him from loosing focus of that textarea, unless he is clicking on #name
.
I've tried the following:
// Prevent loss of focus for textarea
$("#content").on("blur", function(event) {
$('#name').mouseover(function() {
return true;
});
event.preventDefault();
this.focus();
return false;
});
It works just fine to prevent loss of focus of an element. But my idea of checking if he's hovering #name
and returning just doesn't work.