2

Hey guys I am trying to disable a link from being clicked. I tried using a CSS solution:

.link-disabled {
    pointer-events: none;
    cursor: default;
}

It doesn't work in IE10 and below. Is there a CSS or jQuery solution to this?

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
SirMissAlot
  • 120
  • 2
  • 11

1 Answers1

4
$('.link-disabled').click(function(){return false;});

Explanation:

return false; in an event handler prevents the default action and stops the event propagation through the DOM.

Fiddle

Let me know if this was useful.

Alberto
  • 1,853
  • 1
  • 18
  • 22
  • Yes @RoryMcCrossan: this will disable on all browsers but that's what SrMissAlot wanted. Indeed she said: 'i went on css solution : but in don't work in IE10 and below'... – Alberto Sep 25 '15 at 12:47
  • @SrMissAlot: I updated the answer with a fiddle, please check it ;) – Alberto Sep 25 '15 at 13:55
  • Note: This solution doesn't handle the situation where the user accesses the link using the Context Menu or the scroll button! – Alexandru Severin Aug 02 '17 at 11:55