Answer the question
In order to leave comments, you need to log in
How to close the modal window with the same button and change the text of the button?
Hello guys!
Such a question:
There is a button with the inscription "Submit", when this button is pressed, a modal window opens, how in javascript to make it so that after pressing the button and opening the modal window, the text of the button itself changes to "Cancel" and when you click on it, the window closed.
I just re-open the window with each click and the text can not be changed.
Thank you.
Answer the question
In order to leave comments, you need to log in
document.querySelector("button").onclick = function(){
var has = this.classList.toggle("open");
this.textContent = has ? "Отмена" : "Отправить";
if(has){
//Открыть окно
}else{
//Закрыть окно
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question