I have html that looks something like the below.
dataId
below is the data-id that has just been scrolled over. At this point I want to get the closes data-id
to this element. I have taken many approaches, unfortunately none of which are working.
<div data-id='12345'>
<p>hello there</p>
</div>
<div class='break'>
<p>no man's land</p>
</div>
<div data-id='5678'>
<p>Go for it</p>
</div>
<div class='test'>
<p>just a test</p>
</div>
<div class='example'>
<p>example</p>
</div>
<div data-id='5789'>
<p>Last one</p>
</div>
The js looks like this:
const firstDiv = $('div').attr('data-id["12345"]')
const nextDiv = firstDiv.next().attr('data-id');
// I am looking for the nextDiv to give me 5678