Disable link using javascript

前端 未结 2 855
逝去的感伤
逝去的感伤 2021-01-14 06:13

I have following HTML and would like to disable the link using javascript.



        
2条回答
  •  伪装坚强ぢ
    2021-01-14 06:59

    document.getElementById("uc_ii_lnkInstall").onclick = function() { return false; };
    

    The return value of false in the old-style event handler prevents the default action (i.e. loading the javascript: URL).

    If you want to gray out the image link, you would also need to swap out the image's src URL with one pointing to a grayed-out version of the icon and change the text's color using .style.color = "gray";.

提交回复
热议问题