Skip to content
Advertisement

jQuery: Checking if next element exists

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

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

What am I doing wrong? Thanks a lot!

Advertisement

Answer

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

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement