jQuery – how to check if an element exists? April 26, 2023 by Tarik You can use length to see if your selector matched anything. if ($('#MyId').length) { // do your stuff }