Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set image to be tabbable

Tags:

html

I have an image and I want the user to be able to naviagte to it using the tab button. I am unable to set the tab-index due to the way the page is changed dynamically. How can I set the image to be tabbable?

like image 426
Mark W Avatar asked Dec 02 '25 13:12

Mark W


1 Answers

Try wrapping them inside anchors <a tabindex="1"><img src="..." /></a> and set tabindex attribute to dynamically created elements $("<a>").attr("tabindex",tabindex):

var anchor = $("<a>").attr("href",image_link).attr("tabindex", tabindex);
var img = $("<img>").attr("src", image_src).appendTo(anchor);

See this example http://jsfiddle.net/EsEeN/

like image 94
I.G. Pascual Avatar answered Dec 04 '25 01:12

I.G. Pascual



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!