because my javascript code does not allow me to change the image more than once?

-1

I am using the following code, it only lets me change the image once and then it does not make any more changes it is supposed to change every time I click

     <script>

    $(document).ready(function () {
        var opn = 0;

        $('#este').click(function () {
            if (opn == 0) {
                document.getElementById('change').src = "css/galeria/flechita_blanca.png"
                opn = 1;
            }
        });



        $('#este').click(function () {
            if (opn == 1) {
                document.getElementById('change').src = "css/galeria/down.png"
            }
            opn = 0;

        });
    });


</script>
    
asked by Emanuelle Garcia 11.06.2018 в 17:19
source

1 answer

0

try this

  var opn = 0;
  $('#este').click(function () {
    if (opn == 0) {
        document.getElementById('change').src = "css/galeria/flechita_blanca.png"
        opn = 1;
    }else{
        document.getElementById('change').src = "css/galeria/down.png"
        opn = 0;
    }
    });

you're crossing the functions ...

    
answered by 11.06.2018 в 17:26