if ($(selector).length) {
    // Exists
}

Source: http://stackoverflow.com/a/587408