Skip to main content
Jhon Carlo
Inspiring
August 3, 2018
Answered

Is it possible to disable a buton of btn-group-justified?

  • August 3, 2018
  • 2 replies
  • 1104 views

Hi,

this is my  btn-group-justified:

<div class="btn-group btn-group-justified" role="group" aria-label="Justified button group with nested dropdown">

<a onClick="DisabeButton(); " href="#" style="background: #E39C9D" class="btn btn-default" role="button" id="MyBtnOne">Button 1</a>

<a href="#" style="background: #E39C9D"  class="btn btn-default" role="button" id="MyBtnTwo">Button 2</a>

</div>

This doesn't work:

function DisabeButton() {

            document.getElementById("MyBtnTwo").disabled = true;

        } 

</script>   

Any help?

Thanks.

    This topic has been closed for replies.
    Correct answer BenPleysier

    You are not using buttons, but anchor tags. Anchor tags do not have a disabled attribute.

    Change the anchor to a button and you can apply the disabled attribute.

    2 replies

    BenPleysier
    Community Expert
    BenPleysierCommunity ExpertCorrect answer
    Community Expert
    August 3, 2018

    You are not using buttons, but anchor tags. Anchor tags do not have a disabled attribute.

    Change the anchor to a button and you can apply the disabled attribute.

    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
    BenPleysier
    Community Expert
    Community Expert
    August 3, 2018

    To add to my previous reply, have a look at How to Disable Links | CSS-Tricks

    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
    Legend
    August 3, 2018

    BenPleysier  wrote

    To add to my previous reply, have a look at How to Disable Links | CSS-Tricks

    Just another persons opinion, neither are they right or wrong. There may well be a reason to disable a link based on some kind of questions and answers - anyone that says its incorrect is in denial, but hey so many in this business are self-focused idiots who'll gladly reverse their tiny minded thoughts, when, if and as soon as the boot fits.

    I have no idea why the OP wants to disable a 'link' as the link at the moment appear to be going nowhere, yet strangely mentioned 'button' in the post, which are currently nowhere to be seen.

    Edited.

    I cant think of a valid reason for actually 'disabling' any html element to be honest. If its not an itegral part of the user experience then set its attributes to display: none; on an event.

    Legend
    August 3, 2018

    Disable an 'anchor' tag:

    <script>

    function DisabeButton() {

    const disableLink = document.querySelector("#MyBtnTwo");

    disableLink.setAttribute("style", "color: grey; background-color: #d9d9d9;");

    disableLink.setAttribute('href', "#");

    return false;

    }

    </script>