Check if a certain element exists anywhere in the DOM

Apr 9, 2013 07:29 · 36 words · 1 minute read js

Using jQuery to determine if there’s any element with a certain class on the current page:

    // check if an element with class 'footable' exists, then call footable() on it
    if($('.footable')[0]) {