Disable an anchor tag using jQuery

A quick snippet on disabling an anchor tag.

1
2
3
4
jQuery("li.special-tag > a").click(function(e){
            e.preventDefault(); // prevent the default action of anchor tag
            return false;
}).css("cursor", "default");

Reference


facebooktwittergoogle_plusredditpinterestlinkedinmail

SIGN UP TO OUR NEWSLETTER

Stay tuned with latest updates on Web technologies, subscribe to our newsletter. We'll not spam your inbox.

Speak Your Mind

dialog-information.png

Code highlighting instructions

Use {code type=language} for code highlighting. For example, if you are using Javascript code then use the following to wrap.

{code type=javascript}
//Your code here
{/code}

or for PHP, use:

{code type=PHP}
// Your code here
{/code}

 

*

CommentLuv badge

Security Code