In order to check if an element exists, you need to find a selector that matches only that element and check if the length of the jQuery object is equal to 0 or not, like so:
if ($('#unique-selector').length === 0) {
// code to run if it isn't there
}
else {
// code to run if it is there
}