I have a function that is called in a onclick in my <img> that calls.
function opengal(id){
document.getElementById('gal_img').innerHTML="<img id='gal_active' src='" + imgs_array[id].source_t + "' />";
gal_id = id;
$(document).ready(function(){
showId('gal');
showId('gal_back');
$('gal').fadeTo(3000, 1);
$('gal_back').fadeTo(3000, 0.9);
if (gal_id + 1 === imgs_array.length) {
$('next').fadeTo(3000, 0);
hideId('next');
showId('prev');
$('prev').fadeTo(3000, 1);
} else if (gal_id === 0) {
$('prev').fadeTo(3000, 0);
hideId('prev');
showId('next');
$('next').fadeTo(3000, 1);
} else {
showId('prev');
showId('next');
$('next').fadeTo(3000, 1);
$('prev').fadeTo(3000, 1);
}
});
}
The showId and hideId calles a document.getElementById(id).style.visibility="" to show the elements that are hidden for a slideshow-like gallery that is set above the rest of the page. after it shows these elements its suppose to change its opacity to fadeIn the element. The elements are being shown, but not the animation.
I think the cause is because the function is called outside the rest of my $(document).ready() as the imgs are generated in php for loop for displaying images from my database, with each image having its own id and calling its own opengal(id)