+ 3

I want a JavaScript program :- When I click a button 10 times after this we can access another button.

My program is not working so I have problem so please any one give me solution.

1st Sep 2019, 4:42 AM
PRINCE KUMAR
7 ответов
+ 2
Kostas Šliažas Thanks you also for helping me
1st Sep 2019, 3:10 PM
PRINCE KUMAR
+ 1
I wrote this up real quick, it creates a new button and appends it to the body tag after clicking the current one ten times. I don't know if this is exactly what you need but hopefully this will give you some ideas. You can use this if you'd like: let clickCount = 0; let currentButtonCount = 0; let currentButtonId; function createButton() { let myButton = document.createElement("BUTTON"); let body = document.getElementsByTagName('body'); currentButtonCount++; currentButtonId = `myButton${currentButtonCount}`; myButton.innerHTML = `This is button ${currentButtonCount}`; myButton.setAttribute('id', currentButtonId); body[0].appendChild(myButton); myButton.addEventListener('click', youClickedtheButton); } function destroyButton() { let doomedButton = document.getElementById(currentButtonId); doomedButton.parentNode.removeChild(doomedButton); createButton(); } function youClickedtheButton() { clickCount++; if (clickCount % 10 != 0) { return; } else { destroyButton(); } } createButton();
1st Sep 2019, 6:10 AM
Foobatboy
Foobatboy - avatar
+ 1
Fuzzy Squid This is code where I insert the number function to click 10 times first button to show another button https://code.sololearn.com/Wk111xHFyL0m/?ref=app
1st Sep 2019, 7:38 AM
PRINCE KUMAR
+ 1
Coder Thankyou So Much you helped me alot
1st Sep 2019, 3:10 PM
PRINCE KUMAR