Search code examples
javascriptasp.netthickbox

How to disable anchor tag after first click in javascript ?


I have a a href tag with css class thickbox I need to disable the link after first click. how I can do this?

Aspx code

<a href="SomePage.aspx?FDID=11&KeepThis=true&TB_iframe=true&height=150&width=400"
     onclick="return DoSomething(this)" class="thickbox" id="AnchorID">
<img id="MyImageButton" alt="Image" src="SiteImages/image.png" runat="server" />
</a>

My JavaScript Method

function DoSomething(element) {

                return true;
            }

Solution

  • In your javascript you can set the attribute disabled="" at your element. (look here)

    If, with disable, you mean to not let the browser go to the url, you have to call event.preventDefault() (look here)