How to access a div by clicking a tab using javascript?

I implemented something that looks like this: if the user clicks on a div, the image changes in another div:

<div id="actionDiv" onClick="changePic();">Change Pic</div>
<div id="picHolder"></div>

Thus, this “Change Pic” text can be easily obtained with the mouse. How do I get focus from a tab key in an actionDiv text div for accessibility?

+3
source share
1 answer

I'm not sure, but the question seems similar to this how-can-i-give-keyboard-focus-to-a-div-and-attach-keyboard-event-handlers-to-it , and the answer is mainly about providing an attribute diva tabIndex, i.e.:

<div id="actionDiv" tabIndex="0" onClick="changePic();">Change Pic</div>
+4
source

Source: https://habr.com/ru/post/1778418/


All Articles