San San - 1 year ago 71
jQuery Question

How to unselect a link using jquery

Its a bit difficult to explain, but i will try.

Whenever someone clicks on a anchor link, temporarly a dotted box appears around it.
For example, when you click on the stackoverflow logo over the top of this page, it
is surrounded by a dotted line temporarily. Because the page gets refreshed, the dotted box goes away.

But with ajax, the link doesnt get refresh, hence the dotted box remains on it.
How to remove that dotted box. When you click somewhere on the page the dotted box goes away.
How to do it using jquery or any other way.

Answer Source

To un-select it you can trigger the blur event on the anchor element, for example:

$('a').click(function () {
  this.blur(); // or $(this).blur();

element.blur() will remove the keyboard focus from the current element.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download