www.webdeveloper.com
Results 1 to 3 of 3

Thread: when i click a button it goes away or at least the onClick function help please???

  1. #1
    Join Date
    Jun 2013
    Posts
    10

    Exclamation when i click a button it goes away or at least the onClick function help please???

    I want to make a button so when you click it it does its command then it unloads itself or something like that or it just gets deleted any advice...

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,373

    Lightbulb

    You don't specify what is to occur WHEN the button is clicked, so I just did an alert message.

    Code:
    <!DOCTYPE HTML>
    <html>
    <head>
    <title> Untitled </title>
    <meta charset="utf-8">
    <script type="text/javascript">
    function removeButton(IDS) {
      alert(IDS);  // do whatever function is to occur when button is clicked
      document.getElementById(IDS).style.display = 'none';
    }
    </script>
    
    </head>
    <body>
    <button id="btn0" onclick="removeButton(this.id)">Button 1</button>
    <button id="btn1" onclick="removeButton(this.id)">Button 2</button>
    <button id="btn2" onclick="removeButton(this.id)">Button 3</button>
    <button id="btn3" onclick="removeButton(this.id)">Button 4</button>
    <button id="btn4" onclick="removeButton(this.id)">Button 5</button>
    
    </body>
    </html>
    Good Luck!

  3. #3
    Join Date
    Jun 2013
    Posts
    10
    Thanks it worked!!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles