exile_au
exile_au

Reputation: 55

How to Hide a HTML Button

I have a button that calls a function when it is clicked. I want it to hide when some one clicks on it.

HTML:

<DOCTYPE html>
<html>
    <head>
        <title>Example</title>
        <link rel="stylesheet" type="text/css" href="style.css">
    </head>
    <body>
        <p id="Displayer"></p>
        <button onclick="Set()">Ready?</button>
        <script type="text/javascript" src="javascript.js">
        </script>
    </body>
</html>

Upvotes: 2

Views: 50

Answers (1)

dovetalk
dovetalk

Reputation: 1991

Pass in your element and then set the display style to none:

HTML:

<button onclick="set(this)">Ready?</button>

Javascript:

function set(elem) {
    elem.style.display = "none";
}

Upvotes: 2

Related Questions