Using jQuery length property, we can ensure whether element exists or not.
$(document).ready(function(){if ($('#element').length > 0){//Element exists});});