I have an image which is an arrow for sorting the list. When i click it has to change to other image which is downward of the same image. But it doesn't stay that way after clicking. . I need if else statement here because i will need the reverse list with new image after first click. It's not all of my Javascript. I tried to copy the parts which are related to my question. I hope it is an understandable example.
const sorting = document.querySelector('#sortingIcon');
let arr = [];
sorting.addEventListener('click', (event) => {
if (sorting.src = "images/Group74.png") {
sorting.src = "images/Group90.png";
const items = document.getElementsByTagName('li');
for (let i = 0; i < items.length; i++) {
console.log(items[i])
arr.push(items[i].firstChild.value);
}
arr.sort();
for (let i = 0; i < items.length; i++) {
items[i].firstChild.value = arr[i];
}
}
})
<div class="box">
<div id="yellow"></div>
<h1>To-do list</h1>
<img id="sortingIcon" src="images/Group74.png" alt="sorting">
<div id="inputBox">
<input class="input" type="text" name="input1">
<img class="clear" src="images/Group77.png" alt="">
</div>
<button id="plus_button">
<div id="flex">
<div id="plus">+</div>
<div id="enter">Добавить </div>
</div>
</button>
</div>
How can i make it stay that way?