This is my PHP code for displaying the image:
<?php
//reads in the file
$file = file("pokedex.txt");
foreach($file as $ind=>$line){
$contains = stripos($line, "#");
if ($contains === false) {
echo "<p>".$line."</p><br/>";
} else {
$i = $ind / 2;
echo "<div class = 'picture-wrapper' id = 'picture-".$i."'>";
echo "<img src = 'img/picture-".$i.".jpg' class = 'picture-icon'/>";
echo "<span>".$line."</span></div>";
}
}
?>
where $i is the number of each image, I have 5 images and the line
echo "<img src = 'img/picture-".$i.".jpg' class = 'picture-icon'/>";
echoes out each image. The variable $i pertains to each image number. I have successfully been able to write code that turns each of the 5 images to one (same) image when the user hits a "pictureReturn" button:
$('[name="pictureReturn"]').click(function(){
$(".picture-icon").attr("src", "img/picture.jpg");
});
How do I use jquery so that when a user hits a "pictureShow" button, the image will change from picture.jpg to the original 5 pictures?: <img src = 'img/picture-".$i.".jpg' class = 'picture-icon'/>
Thanks!
Aucun commentaire:
Enregistrer un commentaire