Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I hide a button in html?

Tags:

html

button

I am a beginner in HTML. How would I make a button that would hide itself when clicked using JavaScript? This is the code I have already, missing a line.

<!DOCTYPE>
<html>
    <body>
        <button type="button" onclick="delete()" = ;>Hello</button>
        <script>
            var delete = function(){
            //hide button
            }
        </script>
    </body>
</html>     
like image 345
user2607534 Avatar asked May 26 '26 07:05

user2607534


1 Answers

delete is a keyword in js. Use a different name

onclick="deleteThis(this)"



var deleteThis = function(elem){
        elem.style.display = 'none';
        // elem.style.visibility = 'hidden';
};
like image 65
jozzy Avatar answered May 27 '26 19:05

jozzy