Answer the question
In order to leave comments, you need to log in
How to change link text after clicking link in JS?
For example: <a href="#">Добавить товар</a>
Replace after clicking on:<a href="#">Добавлено</a>
Answer the question
In order to leave comments, you need to log in
Without jquery, somehow, instead of getElementById, you can use other type selectors: getElementsByTagName, getElementsByClassName, querySelectorAll ( read more here ), but keep in mind that they return an array of elements, unlike getElementById and querySelector. They should be used in order not to give all elements a unique id if there are many of them.
<script>
document.getElementById('demo').addEventListener('click', function (event) {
event.preventDefault(); //отключает переход по ссылке
this.innerHTML = 'Добавлено';
})
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question