+ 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.
7 ответов
+ 2
Kostas Šliažas Thanks you also for helping me
+ 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();
+ 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
+ 1
Coder Thankyou So Much you helped me alot