Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

306
Visualizações
How can i make something stay that way after clicking is done?

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?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda