Let’s say I have some structure like:
<ul>
<li>
<input .../>
</li>
<li>
This item doesn't have an input
</li>
<li>
<input .../>
</li>
<li>
<input .../>
</li>
</ul>
Given a reference to one of the input elements, how can I get the next or previous input in the list?
Edit: some <li> elements don’t have an input; I need the code to handle those cases.
I ended up using something inspired by this answer: