jQuery – Check Element Existence

Check the existence of an element by the following if condition.

if ($("#mydiv").length > 0) {
  // do something if mydiv exists
}

 

Done =)

Reference: How to check whether an element exists using jQuery

2 thoughts on “jQuery – Check Element Existence”

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.