gajendra kumar gajendra kumar - 3 months ago 4
Javascript Question

Not able to capture focus on desired element by js .focus()

When i call

$('#someelement').focus()
it doesn't give any error message but practically not working. When i try to get
document.activeElement
it still returning
body
element.

Below is my console result:

enter image description here

Answer

You are calling .focus for #IncomeExpense_wrapper and that is <div> and div does not have focus event, only input elements does.

Can't help further, because you provide no info on what focusing on div must do.

Comments