How can I find the second closest div?
For example, to get the closest one, I am successfully using:
var closest_div_id = $(this).closest('div').attr('id');
Now, how do I get the second closest? Something like:
$(this).(closest('div').closest('div')).attr('id'); ???
Assuming
thisis not a<div>element, you can pass a selector to parents() and write:parents()returns the ancestors ordered from the closest to the outer ones, soeq()can be used here. See this question for the general case.