Вопрос

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?

Это было полезно?

Решение

Have you tried both?

$('.selector').nextAll().each(function() { 
  console.log(this);
});
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top