Francisco14 Posted July 7, 2015 at 07:35 AM Report #585829 Posted July 7, 2015 at 07:35 AM Boas precisava de ajuda para concluir este código que tem como função trocar de imagem após atingir 50 clicks. <html> <head> <title>Troller Heroes</title> </head> <img src="1221.png" width="100" height="100"> <br> <body> <script type="text/javascript"> var clicks = 0; function onclick() { clicks += 1; document.getElementById("clicks").innerHTML = clicks; if(clicks == 50) { images[1] = "tr2.png"; } }; </script> <button type="button" onclick="onclick()">Monster</button> <p>HITS: <a id="clicks">0</a></p> </body> </html>
HappyHippyHippo Posted July 7, 2015 at 11:15 AM Report #585840 Posted July 7, 2015 at 11:15 AM da mesma forma que acedes ao elemento que apresenta o número de "clicks" já efectuados, terás de aceder ao elemento da imagem e alterar o atributo src através do método setAttribute IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
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