jQuery: Check if an Element Is on the Page

If you’re using ajQuery an need to know if a certain element exists on the page you can simply do this:

if ($('article.post').length > 0) {
    // element exists
} else {
    // element does not exist

That is all.

Creating your first programming language is easier than you think.

Understanding how a programming language works is a surefire way to be a better developer. Read more.

Suggested Reading

written by Ryan Bosinger
Ryan is a web developer living and working in Banff Alberta. He also writes for giftsforpeoplewitheverything.com and freefoley.com.

Leave a Reply