0

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

Bobby Jack
  • 15,689
  • 15
  • 65
  • 97
Pavan Kumar
  • 1,616
  • 5
  • 26
  • 38

3 Answers3

2

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

Paul Rumkin
  • 6,737
  • 2
  • 25
  • 35
0

Try something like this

$(body).keyup(function(event) {
    if (event.keyCode == '9') { 
        //select the text
    }
});

As for selecting the text itself. See this answer

Community
  • 1
  • 1
Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308
  • This is my code - http://jsfiddle.net/PuGwE/ The above function is not working with my code. Can you please look my code. – Pavan Kumar Aug 13 '11 at 10:23
0

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>
Eranki
  • 750
  • 1
  • 11
  • 30