Skip to main content
Jhon Carlo
Inspiring
Aug 3, 2018 9:51 AM UTC
Answered

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

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 is closed to new replies. Start a new post to keep the conversation going.
    BenPleysier
    BenPleysierCorrect answer
    Community Expert
    Aug 3, 2018 11:14 AM UTC

    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!

    9 replies

    BenPleysier
    Community Expert
    BenPleysierCommunity ExpertCorrect answer
    Community Expert
    Aug 3, 2018 11:14 AM UTC

    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.

    Translate
    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
    Aug 3, 2018 11:24 AM UTC

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

    Translate
    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
    Legend
    Aug 3, 2018 11:49 AM UTC

    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.

    Translate
    Legend
    Aug 3, 2018 11:13 AM UTC

    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>

    Translate