Answer the question
In order to leave comments, you need to log in
Why is onclick not working?
Changing the text color p to red on button click does not work.
in html:
<p class="intro">textext....text</p>
<a href="#" class="btn" id="btn">Двигаться к мечте!</a>
<script src="js/main.js"></script>
.red {
color: red;
}
var btn = document.getElementById('btn');
btn.onclick = function () {
var text = document.querySelector('p.intro');
text.classlist.add('red');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question