3

I have implemented something, which looks like this: if a user clicks on a div, a picture changes in another div:

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

So this text "Change Pic" can easily be accessed by mouse. How do I get focus from tab key in the text div actionDiv for accessibility?

tanjir
  • 1,294
  • 13
  • 22
  • 2
    possible duplicate of [How can I give keyboard focus to a DIV and attach keyboard event handlers to it?](http://stackoverflow.com/questions/148361/how-can-i-give-keyboard-focus-to-a-div-and-attach-keyboard-event-handlers-to-it) – Andy E Dec 03 '10 at 22:44
  • I could not find while I was searching.. but seems like this is the right direction.. thanks again :) – tanjir Dec 03 '10 at 22:49

1 Answers1

5

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

<div id="actionDiv" tabIndex="0" onClick="changePic();">Change Pic</div>
Community
  • 1
  • 1
andrewmu
  • 14,276
  • 4
  • 39
  • 37