JSFiddle - React, Tailwind, and code Playground
HTML
<div class="entry">
<div class="entry-head">1 | Name: Grimbode ....</div>
<div class="entry-head">2 | Name: Grimbode ....</div>
<div class="entry-head">3 | Name: Grimbode ....</div>
<div class="entry-content">Random message
<form class="test">
<div class="entry-options">
<input type="submit" value="Delete" name="edit" />
<input type="hidden" value="3" name="entryID" />
</div>
</form>
</div>
</div>
JavaScript
$('.test').on('submit', function (e) {
e.preventDefault();
var $this = $(this);
var $this2 = $this.closest('.entry').find('.entry-head');
var $entryID = parseInt($this2.text().split('|')[0].replace(/ /g,''));
alert($entryID);
alert($this2.nextAll('.entry-head').length); // Is 0
$this2.nextAll('.entry-head').each(function (index, value) {
console.log($this2.nextAll('.entry-head').length);
for (i = $entryID; i <= $this2.nextAll('.entry-head').length; i++) {
$(value).text($(value).text().replace(i, (i -1)));
console.log('Index: ' + index + ' | ');
}
});
});