How to apply javascript

-4

I want that when the person clicks on option one and then clicks on the two, the one is cleared.

<script>

        function mudaImagem (foto){
            document.getElementById("vamo") .src =foto;
        }
        function selecionaPequeno(){
            document.getElementById("bora") .src = "imagens/P1.gif";
        }
        function voltaPequeno(){
            document.getElementById("bora") .src = "imagens/P1.png";
        }
        function selecionaMedio(){
            document.getElementById("corre") .src = "imagens/P1.gif";
        }
        function selecionaGrande(){
            document.getElementById("neh") .src = "imagens/G3.png";
        }
        function selecionaGigantesco(){
            document.getElementById("jeh") .src = "imagens/GG3.png";
        }


</script>

HTML

<img src="imagens/P1.png" id="bora" name="opa" onclick="selecionaPequeno()" width="56" height="35" />
<img src="imagens/P1.png" id="corre" name="opa" onclick="selecionaMedio()" width="56" height="35" />
    
asked by anonymous 26.09.2017 / 05:01

1 answer

0

The explanation was not clear but I believe the idea is this:

HTML

<img id="bora" name="opa" src="https://icon-icons.com/icons2/577/PNG/256/ExecutiveCar_Black_icon-icons.com_54904.png"/><imgid="corre" name="opa"src="https://images.vexels.com/media/users/3/127817/isolated/lists/4fd0c9dcae60a9a63579b9b6853eeb09-carro-de-besouro-retro-brilhante.png"/>

JAVASCRIPT

$(document).ready(function(){$("#bora").click(function(){
      $(this).addClass("selected");
      $("#corre").removeClass("selected");
  });
  $("#corre").click(function(){
      $(this).addClass("selected");
      $("#bora").removeClass("selected");
  });
});

CSS

.selected { border: 2px dashed red; }

RESULT

Seeworkinghere: link

    
05.10.2017 / 22:34