3 ms·
// jQuery $el.siblings(); // Native Array.prototype.filter.call(el.parentNode.children, (child) => child !== el ); Yes, much clearer
by kibibu 10y ago
// jQuery
$el.siblings();
// Native
Array.prototype.filter.call(el.parentNode.children, (child) =>
child !== el
);
Yes, much clearer
- petepete 10y agoWhile I'm firmly of the opinion that full jQuery is a fine choice for most projects, if you don't need `$.animate` or favour fetch over `$.ajax` you might be better-served choosing the slim build or smaller libraries that provide only a subset of jQuery's functionality (Domtastic, Zepto, etc)
- pluma 10y agoAlternatively: Array.from(el.parentNode.children).filter( (child) => child != el ) But yes, it's not quite as sexy as siblings().