Jump to content

jquery setting hovers within a loop


astralaaron

Recommended Posts

Hello,

 

I'm having a bit of trouble with jquery.

 

I have something similar to the following:


function someFunction( i ){ 

for(var x = 0; x < numOfPosts; x++) {

		var callbackA = function() {
			console.log('set i=' + i + ' x=' + x);	
		};

		var callbackB = function() {
						console.log('set i=' + i + ' x=' + x);
		};
					
		
		$( element ).hover( callbackA , callbackB );	

}

}

The issue I am having is that x is always equal to the "numOfPosts" for each iteration. Anything obvious that I am doing incorrectly? Thanks everyone for reading.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...