Zuckerberg Zuckerberg - 1 month ago 18
HTML Question

How to get all element siblings in an array in jQuery...?

what i would like to do is get all element siblings in a variable in Jquery to have easy access of all its sibling's properties.
As you can see the structure, the siblings don't have ids or classes or even any attributes on them apart from the tag name,
but how would i get the element with id=>the_only_id_element to return all its siblings without using
$('#the_only_id_element').next().next() .....?

<div id="the_only_id_element"> element one </div>
<div> element two </div>
<div> element three </div>
<div> element four </div>

Answer
<div id="the_only_id_element"> element one </div>
<div> element two </div>
<div> element three </div>
<div> element four </div>


<script>

    //This one is tested!
    var element = $('#the_only_id_element'),
        required_html=$(element).nextUntil(element,0);//returns array / siblings after each other in array...


    //now use array index selector to select any sibling by its position
    console.log( $(required_html[0]).html() )

</script>