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
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
Try something like this
$(body).keyup(function(event) {
if (event.keyCode == '9') {
//select the text
}
});
As for selecting the text itself. See this answer
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>
精彩评论