Eduardo Fuerte
asked on
Could you point how to obtain the control name that has the focus from inside jQuery?
Hi Experts
Could you point how to obtain the control's name that has the focus from inside jQuery?
Thanks in advance.
Could you point how to obtain the control's name that has the focus from inside jQuery?
Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi
I get similar results you had before
I get similar results you had before
// 1st image part - with addition of .name
var focused1 = document.activeElement.name;
// 2nd image part
var focused2 = $(':focus');
alert(focused1);
alert(focused2);
// But this finally works (not very elegant)
var procname;
if ($('#tab18').is(':focus'))
{
procname = '#proc18';
}
else if ($('#tab19').is(':focus'))
{
procname = '#proc19';
}
else if ($('#tab20').is(':focus'))
{
procname = '#proc20';
}
else if ($('#tab22').is(':focus'))
{
procname = '#proc22';
}
else if ($('#tab60').is(':focus'))
{
procname = '#proc60';
}
alert(procname);
Hi Eduardo: you missed my post :)
var focused2 = $(':focus');
return a jQuery object; to get the name you have to use attr() as I have shown above.
ASKER
Thank you Mario!
ASKER
ops... Marco
Open in new window