Having this code:
let ev = document.querySelectorAll('.event p')
for (let i = 0; i < ev.length; i++) {
ev[i].addEventListener("click", function (e) {
// add this only for current clicked elem
e.currentTarget.src = './icon.png';
// And the rest of items should have this:
ev[i].src = './warning.png';
});
}
How can i change warning.png to all elements in this loop, but change src for element to have icon.png that was clicked? So kind of toggle. My code is not working as expected. Thanks.