Любая причина, по которой вы добавляете событие щелчка на <a>
?
iconsred
, не имеет события щелчка, прежде чем запустить changered()
, поэтому вам нужно дважды щелкнуть по нему.
Вы можете сделать это так:
var iconsred = document.getElementById("iconsred")
iconsred.addEventListener('click', function(event) {
event.target.classList.toggle('fas');
event.target.style.color = "#ff0000";
})
Демо
var iconsred = document.getElementById("iconsred")
iconsred.addEventListener('click', function(event) {
event.target.classList.toggle('fas');
event.target.style.color = "#ff0000";
})
<a href="#">
<div class="thumb-down">
<i id="iconsred" class="far fa-thumbs-down fa-5x right">test</i>
</div>
</a>