1
To illustrate what I’m looking for, note the figure:
Screen Shot
For this I put the source code for example:
Code
<html>
<head>
<style type="text/css">
#slide #screenshot {
width: 480px;
height: 360px;
border: solid 3px #333;
}
#slide a {
border: solid 1px #333;
background-color: #F7F7F7;
padding: 5px;
text-decoration: none;
color: #000;
}
#slide a:hover {
border: solid 1px #333;
text-decoration: underline;
background-color: #333;
color: #FFF;
}
#slide a.hover {
background-color: #333;
color: #FFF;
}
#slide #controle {
width: 480px;
height: 360px;
text-align: center;
padding-top: 15px;
}
</style>
</head>
<body>
<div id="slide">
<div id="screenshot">
<img src="screenshot/1.jpg" width="480px" height="360px" border="0" alt="Banner">
</div>
<div id="controle">
<a href="#" onclick="troca(1);"> « Anterior </a>
<a href="javascript:void(0);" id="screenshot1" class="hover" onclick="troca('0');">1</a>
<a href="javascript:void(0);" id="screenshot2" onclick="troca('1');">2</a>
<a href="javascript:void(0);" id="screenshot3" onclick="troca('2');">3</a>
<a href="javascript:void(0);" id="screenshot4" onclick="troca('3');">4</a>
<a href="#" onclick="troca(-1);"> Próximo » </a>
</div>
</div>
</body>
<script>
img = ['1', '2', '3', '4']
indice = 0;
function troca(i) {
if (i == 0 || i == 1 || i == 2 || i == 3) {
indice = i;
} else {
if (indice == img.length - 1) {
indice = 0;
} else {
indice++;
}
}
document.getElementById("screenshot1").setAttribute("class", "");
document.getElementById("screenshot2").setAttribute("class", "");
document.getElementById("screenshot3").setAttribute("class", "");
document.getElementById("screenshot4").setAttribute("class", "");
document.getElementById("screenshot" + img[indice]).setAttribute("class", "hover");
document.getElementById("screenshot").innerHTML = "<img src='screenshot/" + img[indice] + ".jpg' width='480' height='360' border='0' alt='snap shot'>";
}
</script>
<html>
I didn’t define thumbnail at the following links:
<a href="javascript:void(0);" id="screenshot1" class="hover" onclick="troca('0');">1</a>
<a href="javascript:void(0);" id="screenshot2" onclick="troca('1');">2</a>
<a href="javascript:void(0);" id="screenshot3" onclick="troca('2');">3</a>
<a href="javascript:void(0);" id="screenshot4" onclick="troca('3');">4</a>
I preferred to leave by numbers to detect possible mistakes, since it is being created.
My difficulty is in making logical flow control between "next/previous"
I know the problem is here..
if (indice == img.length - 1) {
indice = 0;
} else {
indice++;
}
See if this helps http://answall.com/a/168525/3635 (BS: I wasn’t the one who was negative and I didn’t understand why)
– Guilherme Nascimento
I don’t get it, it’s video or photo?
– Guilherme Nascimento
This is clear, but people (probably) are hoping to try to understand if you want to play a video, photo or other thing to create an example upon the usage you need.
– Guilherme Nascimento
See if the answer helps you
– Guilherme Nascimento