Here's an easy method with jQuery. Add this CSS and JS to your HTML:
Code:
<style type="text/css">
.show-hide div {display: none;}
.show-hide.show div {display: block;}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.show-hide a').click(function(){
var parentDiv = $(this).parent();
// if parents div already has class show, remove it otherwise, add it
if ($(parentDiv).hasClass('show')) {
$(parentDiv).removeClass('show');
} else {
$(parentDiv).addClass('show');
}
});
});
</script>
And modify your PHP to this:
Code:
$files = glob('martingallery/*');
natcasesort($files);
foreach($files as $file){
echo '<div class="show-hide"><a><img src="' . $file . '" height="150px" width="auto"/></a>
<div id="' . $file . '"><img src="' . $file . '" height="auto" width="auto"/></div></div>';
}
Bookmarks