Hi,
You have 2 options:
1. Use jQuery to find the prev / next data from the DOM and generate the HTML on page load
or
2. Don’t use the has_sub_field while loop, instead use a more basic PHP foreach of for loop so you can use the ‘index’ to find the prev (index-1) and next (index+1) rows
Does that help?