If a dom element is :visible, will it always be focussable?
Asked
Active
Viewed 71 times
0
John Conde
- 212,985
- 98
- 444
- 485
Ken Hirakawa
- 7,151
- 10
- 36
- 49
-
See this question: http://stackoverflow.com/questions/1599660/which-html-elements-can-receive-focus – Surreal Dreams May 01 '12 at 14:57
3 Answers
0
It's not guaranteed, but you can check to see if an element will fire the focus event.
var focussableEls = [];
$(":visible").each({
if (typeof this.focus == 'function')
focussableEls.push(this.id);
});
console.log(focussableEls);
Rory McCrossan
- 319,460
- 37
- 290
- 318
-
That appears to come back with html, body and every element in the body, not just those that can be focused. http://jsfiddle.net/TEL4J/ – Quentin May 01 '12 at 15:15
0
Check for elements that have a tabindex attribute:
$('[tabindex]')
Alnitak
- 325,660
- 70
- 395
- 481
-
Elements don't have to have a tabindex attribute to be focusable (e.g. an input element is focusable by default). – Quentin May 01 '12 at 15:11