Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to focus an "anchor" element? [closed]

I want to make an a element to gain focus, then press Enter to open the link.

<a id='link'>test</a>

I use $("#link").focus(), but it doesn't work.

How can I do this?

like image 954
hiway Avatar asked Nov 02 '13 08:11

hiway


Video Answer


1 Answers

http://jsfiddle.net/RLJ5r/1/

Works fine.

HTML:

<a href="http://google.com" id="link">test</a>

jQuery:

$("#link").focus();
like image 145
rybo111 Avatar answered Sep 19 '22 08:09

rybo111