Skip to main content

Check if a DOM element is present in jQuery.

// check if a DOM element is present
if ($('#id').length > 0) {
  // do stuff
}