JavaScript: make div#main
focused
document.getElementById("main").focus();
With that it will be automatically focused and still accept click event if you need to do some stuff when clicked, clean!
Hope I was able to put you further.
I have a page with a few How to give focus to one of them on page load, so that the user can use arrow keys to scroll (or even
containers.
HTML: add tabindex attribute to div#main
JavaScript: make div#main
focused
document.getElementById("main").focus();
With that it will be automatically focused and still accept click event if you need to do some stuff when clicked, clean!
Hope I was able to put you further.
- 热议问题