if( $('#selector').length ) // use this if you are using id to check{// it exists}
if( $('.selector').length ) // use this if you are using class to check{// it exists}
//you can use it for more advanced selectorsif(document.querySelectorAll("#elemId").length){}
if(document.querySelector("#elemId")){}
//you can use it if your selector has only an Id attributeif(document.getElementById("elemId")){}