Skip to main content

Useful method to find the next list node in an unordered list from javascript

If we try to use object.nextSibling to get the next list object of an unordered list, it is not always returning a list object. The following method can be use to get the next list object of an unordered list.


function getNextLi(the_li) {

var next_li = false;
if (the_li.nextSibling != null && the_li.nextSibling.nodeName == "LI") next_li = the_li.nextSibling;
return next_li;

}

Comments