How to disable anchor tag link using jquery?

Total Post:19

Points:135
JQuery  HTML 
 496  View(s)
Ratings:
Rate this:
I want to disable click here is my code 
<a href='' id='ThisLink'>some text</a>

 I have done this but it is not working
I can do this easily with a button by adding .attr("disabled", "disabled");
  1. Post:149

    Points:1043
    Re: How to disable anchor tag link using jquery?

    Here is the solution for this. Hope this helps!


    var preventClick = false;
     
    $('#ThisLink').click(function(e) {
        $(this)
           .css('cursor', 'default')
           .css('text-decoration', 'none')
     
        if (!preventClick) {
            $(this).html($(this).html() + ' lalala');

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!