Ich mache eine Diashow und habe einige Probleme mit dem Javascript. Wenn ich einmal richtig klicke funktioniert es gut und dann wenn ich links klicke klappt es auch, aber wenn ich wieder rechts klicke sollte es einfach zum nächsten Bild gehen aber es überspringt es und geht zum nächsten. Wer kennt die Lösung?Diashow Fehlerbehebung mit Javascript
$('#droite').click(function() {
if (photo == 4) {} else {
$('#plateau-gallerie').animate({
left: (-300 * photo) + 'px'
}, 500);
photo++;
}
});
$('#gauche').click(function() {
if (photo == 1) {} else {
$('#plateau-gallerie').animate({
left: (-300 * (photo - 2)) + 'px'
}, 500);
photo--;
}
});
#gallerie {
width: 60vw;
height: 300px;
background-color: #a9a9a9;
border-radius: 10px;
border: 3px solid #999;
margin: 0 auto;
position: relative;
overflow: hidden;
}
#plateau-gallerie {
width: 1780px;
float: left;
top: 50px;
position: absolute;
}
#gallerie img {
height: 200px;
margin: 0 0px 0 80px;
float: left;
}
.bouton {
position: absolute;
height: 100px;
width: 60px;
top: 100px;
background-color: #444;
opacity: 0.7;
cursor: pointer;
z-index: 99;
font-size: 3em;
}
.bouton:hover {
background-color: #222;
}
#gauche{
\t left:15px;
}
#droite{
\t right:15px;
}
<section id="gallerie">
<button class="bouton" id="gauche"><</button>
<section id="plateau-gallerie">
<img src="img/pc-gallerie.jpg" alt="ordinateur">
<img src="img/pc-gallerie.jpg" alt="ordinateur">
<img src="img/pc-gallerie.jpg" alt="ordinateur">
<img src="img/pc-gallerie.jpg" alt="ordinateur">
<img src="img/pc-gallerie.jpg" alt="ordinateur">
<img src="img/pc-gallerie.jpg" alt="ordinateur">
</section>
<button class="bouton" id="droite">></button>
</section>
Jeder bekam eine Idee, warum das so ist?
können Sie Ihren Code in eine Geige setzen? –
wollen Sie den ganzen Code? weil das Teil, das verwendet wird, bereits oben geschrieben ist – Pyrofunto
Etwas, das funktioniert und zeigt, wie Ihr Code funktioniert –