How do you make an anchor link non-clickable or disabled?

后端 未结 18 2078
清酒与你
清酒与你 2020-11-27 02:38

I have an anchor link that I want to disable once the user clicks on it. Or, remove the anchor tag from around the text, but definitely keep the text.



        
18条回答
  •  孤城傲影
    2020-11-27 03:04

    I just realized what you were asking for(I hope). Here's an ugly solution

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

提交回复
热议问题