PlayGames63 0 Posted June 24, 2019 Report Share Posted June 24, 2019 Bom estou a fazer um quiz, e no html eu tenho o seguinte código <input type="image" id="submit" class="grupos" src="imgs/t.png" name="p1" value="1"> só que no js eu não estou a conseguir que quando a pessoa clique na imagem ele consiga pegar o value para no caso saber em que imagem a pessoa clicou alguém sabe como eu posso faze-lo? Obrigado. Link to post Share on other sites
Zex 8 Posted June 24, 2019 Report Share Posted June 24, 2019 <script> function processar1 (botao) { alert( botao.value ) } function processar2 (arg) { alert( arg ) } </script> <body> <input type="image" id="submit" class="grupos" src="imgs/t.png" name="p1" value="1" onclick="processar1(this)"> <input type="image" id="submit" class="grupos" src="imgs/t.png" name="p1" value="1" onclick="processar2(1)"> </body> </html> 1 Report Link to post Share on other sites
PlayGames63 0 Posted June 27, 2019 Author Report Share Posted June 27, 2019 Em 24/06/2019 às 12:35, Zex disse: <script> function processar1 (botao) { alert( botao.value ) } function processar2 (arg) { alert( arg ) } </script> <body> <input type="image" id="submit" class="grupos" src="imgs/t.png" name="p1" value="1" onclick="processar1(this)"> <input type="image" id="submit" class="grupos" src="imgs/t.png" name="p1" value="1" onclick="processar2(1)"> </body> </html> Muito obrigado! Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now