Question

I am just wondering if how can I have a call back function in nextAll function of jquery.

I had tried.

$('.selector').nextAll(function() { 
  console.log("try");
});

But its not working. I read the documentation in jquery website but I notice there are no example of callbacks.

I need the nextAll instead of .each to loop through all the next succeeding element of the selector and get the margin right of each succeeding element then animate them to right. I tried,

$('.selector').nextAll().animate({ right: (margin_right-100)+'px'}, 500);
//I am getting the logic here because it animates all the succeeding 
//element but the problem is that I had to replace the 
//`margin_right` variable because the elements next to the 
//selector differs on margin-right.

Any input guys?

Was it helpful?

Solution

Have you tried both?

$('.selector').nextAll().each(function() { 
  console.log(this);
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top