RendeRR
RendeRR

Reputation: 327

document.getElementById("ID").focus() + Google Chrome

document.getElementById("ID").focus() not work in Google Chrome. Is there any alternative? Thank you.

Upvotes: 2

Views: 3355

Answers (2)

Caleb
Caleb

Reputation: 9458

If you're trying to focus something that can't normally be focused you might need to add a tabindex:

<span id="something" tabindex="0">Something</span>

document.getElementById("something").focus()

Upvotes: 3

Miguel Ventura
Miguel Ventura

Reputation: 10458

Apparently it does work, so I'd suggest that you verify that your ID is correct and that document.getElementById() is returning the element that you were expecting.

Upvotes: 2

Related Questions