I’m having some difficulty passing values and arrays between this two functions
Here’s the code:
$(document).ready(function(){
....
....
var srcImageFS =$('#imageAnimated').attr('src');
var array = [];
$('.myLightbox').each(function(i) {
array.push($('.myLightbox').eq(i).attr('href'));
});
$('#rightArrowFS').click(function(array, srcImageFS ){
alert(array +' || --> ' +srcImageFS );
imageRight();
});
...
...
});
and
function imageRight(array, srcImageFS ){
$('#imageAnimated').fadeOut();
$('#imageAnimated').src(array[i+1]);
$('#imageAnimated').fadeIn();
srcImageFS = $('#imageAnimated').src();
arrowsState(array, srcImageFS );
}
In the example code, you don’t actually try to pass anything to
imageRight– the parameter list is empty. Also, you overwrite the value ofsrcImageFSinsideimageRightbefore using it.srcImageFSis undefined because jQuery couldn’t find asrcattribute on$('#imageAnimated')so your selector might be wrong, too.Will actually call the function with the arguments you want.