+ 3

How to use a button multiple times.

After pressing a button it disappear and executes the function, but i want to not press the button just once.

31st Aug 2017, 12:00 PM
Nicolae Ionescu
Nicolae Ionescu - avatar
4 Answers
+ 3
Maybe you can replace abutton with a clickable div. It can help
31st Aug 2017, 1:04 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 10
Your button isn't gone, it's just hidden behind the output. Very simple fix: Html: <!DOCTYPE html> <html>     <head>         <title>Page Title</title>     </head>     <body>         <button id="btn1" onclick="btn()">=</button>         <div id="output"></div>     </body> </html> JS: function btn(){ var btn2=document.getElementById("btn2");   var out = document.getElementById("output");   out.innerHTML="Hey! What are you doing?"; } Simply added a div and then changed innerHTML of it. The div is positioned after the button, so it remains visible.
31st Aug 2017, 12:22 PM
Tashi N
Tashi N - avatar
+ 8
Could you publish your code at the playground and add a link to it in your post?
31st Aug 2017, 12:07 PM
Tashi N
Tashi N - avatar
31st Aug 2017, 12:13 PM
Nicolae Ionescu
Nicolae Ionescu - avatar