jQuery solution would be fine too
[JavaScript] Get element name that has focus
Moderator: General Moderators
[JavaScript] Get element name that has focus
Is it possible to get element that has focus? (without onfocus an onblur on all elements of course)
jQuery solution would be fine too
jQuery solution would be fine too
Re: [JavaScript] Get element name that has focus
I think I understand what your saying. You want to get the element that has focus rather then setting a callback to an element for the focus event.
I think in order to do that with jQuery you'd need to select every element:
Then set a handle:
I think that'd do the trick. Though, it's untested.
I think in order to do that with jQuery you'd need to select every element:
Code: Select all
$("*")Code: Select all
$("*").focus(function () {
alert(this);
});Re: [JavaScript] Get element name that has focus
perfect, but there is one more problem:
if element is inserted with javascript i dont have focus() function on it, is event like ondomchange or something?
if element is inserted with javascript i dont have focus() function on it, is event like ondomchange or something?
Re: [JavaScript] Get element name that has focus
As far as I know, you'll have to add the .focus listener to each newly added element individually - it won't be caught with the $("*") identifier on $(document).ready().
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.