Disable All Links Within DIV

This JavaScript function will disable all links within the specified DIV by setting the link object to ‘disabled’ as well as removing the ‘onclick’ and ‘href’ attributes. This is a useful JavaScript function for form submissions since it will help prevent the user from clicking another link while an action is pending.

4 thoughts on “Disable All Links Within DIV”

  1. Hi,

    First of all I want to thank you for the piece of code you mentioned here.
    It’s working fine. the links are getting disable in a div when I click on a particular button.
    But again on clicking on another button I want the links to be activated again.

    I tried on the same code you given here.

    function EnableAllDIVLinks(DivId)
    var div = document.getElementById(DivId);
    var anchorList = div.getElementsByTagName(‘a’);

    for(var i = 0; i < anchorList.length; i++)
    anchorList[i].enabled = true;


    Doing this links ar getting activated but showing 'undefined'

    Can you please help me with some tips. It's very urgent.

  2. In response to the comment, here is a modified version and a corresponding function to re-enable the links. Please note the creation of a new attribute for each link that acts as a backup to store the original link.


Leave a Comment