Is it possible to focus on a <div>
using JavaScript focus()
function?
I have a <div>
tag
<div id="tries">You have 3 tries left</div>
I am trying to focus on the above <div>
using :
document.getElementById('tries').focus();
But it doesn't work. Could someone suggest something....?
window.location.hash = '#tries';
This will scroll to the element in question, essentially "focus"ing it.