javascript - Can you put a tabindex on a <a> element in HTML and when it is tabbed to it is clicked instead of hav

I have a bunch of <input>s that I have in a certain tab sequence. The last tab is a <a> tha

I have a bunch of <input>s that I have in a certain tab sequence. The last tab is a <a> that when clicked on adds another <input> to the list. Is there a way to use javascript or just plain HTML to make it so that when the user tabs to that link it executes the link?

I have a bunch of <input>s that I have in a certain tab sequence. The last tab is a <a> that when clicked on adds another <input> to the list. Is there a way to use javascript or just plain HTML to make it so that when the user tabs to that link it executes the link?

Share Improve this question asked Nov 13, 2010 at 21:04 chromedudechromedude 4,31216 gold badges69 silver badges96 bronze badges 4
  • 3 Doesn't the a element receive focus when you tab to it? If so you can just execute some javascript in onfocus. – Klaus Byskov Pedersen Commented Nov 13, 2010 at 21:07
  • @Klaus, didn't think about that option. I will try that out. thanks. – chromedude Commented Nov 13, 2010 at 21:08
  • @Klaus You should have posted it as an answer :) – Draco Ater Commented Nov 13, 2010 at 21:09
  • If the A only adds the INPUT on CLICK, it should only add the INPUT on ENTER. If you want it to add the INPUT on TAB, it should also add the INPUT on hover. Else your mouse-keyboard navigation shows different behaviour. – Konerak Commented Nov 13, 2010 at 21:10
Add a ment  | 

2 Answers 2

Reset to default 5

Doesn't the a element receive focus when you tab to it? If so you can just execute some javascript in onfocus

Yes,

You can use the anchor onfocus event. See:

<a href="#123" onfocus="Test(this);">Test</a>

And the function "Test" must read the "href" attribute, something like:

        function Test(target)
        {
            location.href = target.getAttribute('href');
        }

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745559506a4633020.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信