0
Basically I have a class, and every item in this class has a id
, how do I check this id
is equal to a specific value? and, if it detects such value, how to change to a different image?
My code is like this:
<img class="figuras id="quad" src="quadrado.jpg" onclick="trocaFigura()" alt = "quadrado" style = "width: 200px;">
<img class="figuras id="pen" src="pentagono.jpg" onclick="trocaFigura()" alt = "pentagono" style = "width: 200px;">
<img class="figuras id="tri" src="triangulo.jpg" onclick="trocaFigura()" alt = "triangulo" style = "width: 200px;">
<img class="figuras id="exa" src="exagono.jpg" onclick="trocaFigura()" alt = "exagono" style = "width: 200px;">
<script>
function trocaFigura(){
var form = document.getElementsByClassName("figuras");
if()
}
</script>
This does not work for the item that was clicked on. This will only "select" the first class element
nome_da_classe
. Note that the question is based on an event contextclick
.– Luiz Felipe
Really, I complemented the reply, thank you Luiz
– Jaffe.Marques