Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

304
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda