javascript
Galera estou aprendendo javascript, ai fiz um exercicio na escola para criar uma galeria de imagens, la deu certo mas fui refazer aqui em casa e nao esta funcionando, alguem pode me ajudar?
HTML
<!DOCTYPE html>
<html lang="pt-br">
<head>
<title>Galeria em JS</title>
<script type="text/javascript" src="js.js"> </script>
<style type="text/css" rel="stylesheet">
#corpo{
position:relative;
width:500px;
height:auto;
overflow:hidden;
margin:auto;
background:#cdcdcd;
}
#imgfull{
width:500px;
height:400px;
}
a{
width:160px;
height:160px;
margin-left:5px;
display:block;
float:left;
}
.imth{
width:160px;
height:160px;
}
</style>
</head>
<body>
<section id="corpo">
<img src="imagens/img1.jpg" id="imgfull" title="Imagem Grande" alt="Imagem grande" />
<a href="javascript:troca(1)" id="link_img1" >
<img src="imagens/img1_thumb.jpg" id="img1_thumb" class="imth" title="Imagem Grande" alt="Imagem grande" />
</a>
<a href="javascript:troca(2)" id="link_img2" >
<img src="imagens/img2_thumb.jpg" id="img2_thumb" class="imth" title="Imagem Grande" alt="Imagem grande" />
</a>
<a href="javascript:troca(3)" id="link_img3" >
<img src="imagens/img3_thumb.jpg" id="img3_thumb" class="imth" title="Imagem Grande" alt="Imagem grande" />
</a>
</section>
</body>
</html>
JS
function troca(){
if(troca===1){
document.getElementById("imgfull").src="imagens/img1.jpg";
}else if(troca===2){
document.getElementById("imgfull").src="imagens/img2.jpg";
}else{
document.getElementById("imgfull").src="imagens/img3.jpg";
}
}Discussão (4)
Carregando comentários...