How do I reset the value of a button when the modal is closed?
-
Good afternoon, please help me solve the problem.
There is a website with goods, 20 pcs.
Each product opens in its own modal window (on bootstrap 4).
All products have the same "Add to cart" button; clicking on it changes the caption to "Added".
As a result, if you close the modal window of the first product and go to the next, the inscription on the "Added" button is saved for everyone.
How to make it so that when the modal is closed, the value is reset to the initial "Add to cart"?
let btn = $('.add_item'); btn.on('click', e => { $('.add_item').html("Добавлено"); });
JavaScript Anonymous, Aug 24, 2020 -
When the modal close event occurs, change the text on the button as well.
{
// Где-то в обработчике события закрытия модалки
// Прочий код
// ...
$('.add_item').html("Добавить в корзину");
}
the answer is already in the question:
"when closing the modal , you just need to reset the value of the button"Anonymous
2 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!