Sam
Sam

Reputation: 325

Hiding a button on click

Trying to hide a button on click using Bootstrap/JavaScript. Here is my button code:

<a href="#menu-toggle" class="btn btn-primary btn-lg" id="menu-toggle" onclick="hideBtn();">I understand</a>

Here is my script:

<script type="text/javascript">
    function hidebtn(){
        document.getElementById('menu-toggle').style.display = 'none';
    }
</script>

It isn't working, any thoughts? Thanks!

Upvotes: 0

Views: 148

Answers (2)

user3782541
user3782541

Reputation:

Try it with jQuery:

function hide(){
    $( "#button" ).addClass( "hide" );
}

HTML & CSS:

<a id="#button" onClick="hide()">Button</a>

#button.hide {
display: none;
}

Upvotes: 1

akash
akash

Reputation: 2157

function hideBtn()
    {
    document.getElementById('menu-toggle').style.display = 'none';
    }
<a href="#menu-toggle" class="btn btn-primary btn-lg" id="menu-toggle" onclick="hideBtn();">I understand</a>

Upvotes: 0

Related Questions