Lucas Veiga Lucas Veiga - 3 months ago 49
Javascript Question

jQuery: Checking if next element exists

is there a way to check if an next element exists? Check my code:

if($("#people .making-of .mask ul li.current").next("li") != null) {
alert("Exists");
}
else {
alert("Dont exists");
}


What im doing wrong? Thanks a lot!

Answer

Have you tried looking at .next('li').length?

Comments