JSFiddle - React, Tailwind, and code Playground
by lbstr
HTML
<ul id="u">
<li id="a">a</li>
<li id="b">b</li>
<li id="c">c</li>
<li id="d">d</li>
</ul>
CSS
.red { color: red; }
.bold { font-weight: bold; text-decoration: underline; }
JavaScript
$.fn.neighbors = function(){
var newCollection = this.prev().add(this.next());
return this.pushStack(newCollection, "neighbors", "");
};
$('#b')
.neighbors()
.addClass('red')
.end()
.addClass('bold');