a = $('div:first');
b = $('div');
b
may contain multiple DOM elements.
But a
only contains 1 element.
How do I know if a
is the last element of b
?
I tried a == $('div:last')
,but it's wrong after my test.
And if a
is an element of b
, how do I get the sibling of a
within b
?
Clarify
the problem is how I can write a is_a_last_of_b(a, b)
to check whether a
is the last child of b
.
And if a
is a direct child of b
,how to write next_sibling(a)
to return the next sibling of a
(only one)?