I’m trying to access the id of the element nextElementSibling in the array presented in the picture below:
items[3].item.nextElementSibling.attr('id'))
This query does not work. Whereas I can access the id of the item element like so:
items[3].item.attr('id'))
Can someone explain me why the second works, whereas the first does not work!?
Thanks for your help!


.attr()is a jQuery function, but you are not testing it on a jQuery object ($()). Just get its id directly with normal JavaScipt:Or wrap it in
$()to access jQuery functions: