Try :
var nextSectionWithId = $(this).closest("section").nextAll("section[id]:first");
or
var nextSectionWithId = $(this).closest("section").nextAll("section[id]").filter(':first');
You cannot use next because next will look for a match only in the next element. So you can instead use nextAll combined with :first in the selector.
Update
You can use the first() method in jquery to fetch the first element in the collection as well which seems like a faster option.
var nextSectionWithId = $(this).closest("section").nextAll("section[id]").first();
Probably could be this reason:
Because :first is a jQuery extension and not part of the CSS specification, queries using :first cannot take advantage of the performance boost provided by the native DOM querySelectorAll() method. To achieve the best performance when using :first to select elements, first select the elements using a pure CSS selector, then use .filter(":first").
Coutesy @T.J. Crowder