jquery nextUntil has element
- by Mark
jquery nextUntil has element
I have a bunch of elements like this:
<div></div>
<span></span>
<table></table>
<div></div>
<span></span>
<div></div>
I need to check whether or not there's a table element in between the divs, and if so do something.
$('div').each(function () {
if ($(this).nextUntil('div').include('table')) {
$(this).addClass('got-a-table');
}
}
Something like this? I know that there's no include method, is there something that can get me what I need?
Thanks.
Result should be like this:
<div class='got-a-table'></div>
<span></span>
<table></table>
<div></div>
<span></span>
<div></div>