Reputation: 885
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 );
}
Upvotes: 0
Views: 149
Reputation: 1845
In the example code, you don't actually try to pass anything to imageRight
- the parameter list is empty. Also, you overwrite the value of srcImageFS
inside imageRight
before using it.
srcImageFS
is undefined because jQuery couldn't find a src
attribute on $('#imageAnimated')
so your selector might be wrong, too.
imageRight(array, srcImageFS);
Will actually call the function with the arguments you want.
Upvotes: 1
Reputation: 12705
in the document.ready function where ur calling the imageRight() function u should instead call imageRight(array, srcImageFS ) ur nt passing any values to the function
Upvotes: 1