Disabling LinkButton doesn't disable the click event in javascript

后端 未结 7 1615
悲哀的现实
悲哀的现实 2020-12-10 09:08

I want to disable a LinkButton clink on the client site.

objLinkButton.disabled = true;
// or 
objLinkButton.disabled = -1;

Th

7条回答
  •  情话喂你
    2020-12-10 09:44

    The simplest way to disable a link (and render it like normal text) without using jQuery is to remove it's href attribute entirely.

    For example here is the rendered link:

    Click me
    

    And the required JavaScript:

    function disableLink(id) {
       document.all[id].removeAttribute('href');
    }       
    

    This works for me in both IE and Firefox, but you may wish to do some more extensive testing.

提交回复
热议问题