[jQuery] How to load picture after picture (take 2)
I've now reworked my sample and it finally loads picture after picture
yet it doesn't show them. My code is now
var files = new Array();
files = <?PHP echo $json->encode ($files) ?>;
var pos = 0;
(pos > 0)? $('#prev').show(): $('#prev').hide();
(pos < (files.length-1))? $('#next').show(): $('#next').hide();
$('#prev').bind('click', function() {
$('img.picture:visible').hide()
pos -= 1;
$('#files').html('<img src="'+files[pos]+'"
class="picture">').show();
alert('<img src="'+files[pos]+'" class="picture">');
(pos > 0)? $('#prev').show(): $('#prev').hide();
(pos < (files.length-1))? $('#next').show(): $
('#next').hide();
});
$('#next').bind('click', function() {
$('img.picture:visible').hide()
pos += 1;
$('#files').html('<img src="'+files[pos]+'"
class="picture">').show();
alert('<img src="'+files[pos]+'" class="picture">');
(pos > 0)? $('#prev').show(): $('#prev').hide();
(pos < (files.length-1))? $('#next').show(): $
('#next').hide();
});
<img id="prev" src="images/prev01.png" alt="prev"
style="display:none">
<?PHP
if (count ($files) > 0) {
echo "<img src=\"$files[0]\" class=\"picture\">";
}
?>
<img id="next" src="images/next01.png" alt="next"
style="display:none">
Yo might try it out at http://www.orpatec.ch/index.php?page=gallery.php
I've also tried without the "show()" on the picture with the same
effect.
O. Wyss