This jQuery snippet is useful if you want to check the existence of an element. It is best practice to always check the existence of an element before manipulating it to avoid errors.

<script>
    jQuery(function($) {
        var elem = $('selector');

        if(elem.length > 0) {
            //the element exist. your code here
        }
    });
</script>