Answer the question
In order to leave comments, you need to log in
How to turn on / off the function with one button?
How to enable and disable the function with one button (on pure JS)?
There is such an entry, but it does not work ....
document.querySelector('#offer button').addEventListener('toggle', createContent);
function createContent() {
....
}
Answer the question
In order to leave comments, you need to log in
The function cannot be turned on and off, it can only be called. Two functions can be used:
function createContent() { ... }
function deleteContent() { ... }
const content = function () {
var isCreated = false
const this.change = function () {
if(isCreated) {
isCreated = false
...
} else {
isCreated = true
...
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question