'Is this possible to select with keyboard tab a Span Object?
Is this possible to select with keyboard tab a Span Object? I have applied onclick function to that span. I want to select the span along with anchor tags with keyboard tab button.
Thanks in advance
Solution 1:[1]
No. It's very bad idea to do so! Better is to dynamically add anchor element styled like a span, note that onclick should return false, to prevent browser from loading new page. Here your code
Solution 2:[2]
Try something like this
$(body).keyup(function(event) {
if (event.keyCode == '9') {
//select the text
}
});
As for selecting the text itself. See this answer
Solution 3:[3]
One way to do this is by using tabindex="0" in the span tag. Keeping tabindex="-1" skips the element when tab is used.
<span tabindex="0">Focus this element on tab</span>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Paul Rumkin |
| Solution 2 | Community |
| Solution 3 | Maruthi Eranki |
