Boa Tarde,
tou a fazer um site e precisava de botoes, tou a usar image (nao input type=imagefield), mas nesses botoes eu precisava k onclick trocasse a imagem, ou seja, se tivesse a imagem "on.gif" ficasse "off.gif", e se voltasse a clicar voltava a "on.gif".
ja fiz algumas tentativas e neste momento tá assim:
<html>
<head>
<script type="text/javascript">
function changeSrc(id)
{
var imagem=document.getElementById("id");
if(imagem.src=="botoes/off.jpg"){
imagem.src="botoes/on.jpg";
}
else{
imagem.src="botoes/off.jpg";
}
}
</script>
</head>
<body>
<img id="botao" src="botoes/off.jpg" onclick="changeSrc('botao')" width="107" height="98" />
<br /><br />
</body>
</html>
Porke nao funciona? como é k tem de ficar?
Obrigado
tou a fazer um site e precisava de botoes, tou a usar image (nao input type=imagefield), mas nesses botoes eu precisava k onclick trocasse a imagem, ou seja, se tivesse a imagem "on.gif" ficasse "off.gif", e se voltasse a clicar voltava a "on.gif".
ja fiz algumas tentativas e neste momento tá assim:
<html>
<head>
<script type="text/javascript">
function changeSrc(id)
{
var imagem=document.getElementById("id");
if(imagem.src=="botoes/off.jpg"){
imagem.src="botoes/on.jpg";
}
else{
imagem.src="botoes/off.jpg";
}
}
</script>
</head>
<body>
<img id="botao" src="botoes/off.jpg" onclick="changeSrc('botao')" width="107" height="98" />
<br /><br />
</body>
</html>
Porke nao funciona? como é k tem de ficar?
Obrigado
Última edição: