Making Buttons Appear and Disappear When Clicked

make submit button disappear when clicked

Simply add :

   button.style.visibility = "hidden";

at the end of your SetInput function.

how to make a button appear disappear on click of another button?

Your conditional rendering is good, the problem comes when you are updating your show state , so in your handleShow function make a little change

handleshow() {
this.setState ((prevState) => {
return {
show : !prevState.show
}});}

Plus, change the type submit of show button to type button.
That will do the trick.

How to make rect's disappear and re-appear using onclick buttons

It appears you define r1, r2, and r3 in go1 so they are undefined in go2 and go3.

One solution would be to add

let r1, r2, r3;

above all functions and then within go1 change

let r1 = to r1 = and do the same for the other two r variables.

Also I think you need to change onclick="go1" to onclick="go1()" and do the same for the other two click handlers.


I'd highly recommend fixing your indentation. Good indentation makes problems like this much easier to see. If you find it hard to indent your code properly, try using https://beautifier.io/.

How do I make a button disappear after a certain amount of clicks

Assign id to your button.

<Button id='myButton' onclick="myFunction()">

On every click of button, keep incrementing the counter (I think you know how to do it)

After the counter is reached,
document.getElementById("Your_button_id_here").style.visibility = "hidden";

<script>
var counter=0;
function myFunction() {
//increment counter
counter+=1;
if(counter>4)
document.getElementById("Your_button_id_here").style.visibility = "hidden"
}
</script>

However, I think disabling would be more proper:
document.getElementById("Your_button_id_here").disabled=true



Related Topics



Leave a reply



Submit