In my php file I have this code section to get all jpg files form a folder and put them in to img tags.
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && strtolower(substr($file, strrpos($file, '.') + 1)) == 'jpg') {
echo '<div class="image_slider"><img src ="' . $dir . $file . '"/></div>';
}
}
closedir($handle);
}
and then I want to change displaying image by clicking on a links call previous and next.
To do so I'm using jQuery this way..
To show first image without clicking any thing
$( ".image_slider img" ).first().addClass( "active" );
and then for the other images to load user must clik prvs or next links.
function next_img(){
$( ".image_slider img" ).closest().next( "active" );
}
but this function is not working. It doesn't change the class "active" from first one to second one.
I feel I'm missing something. but couldn't find it.
Thank you