Nick Nick - 1 year ago 114
jQuery Question

Check if element exists in jQuery

How do I check if an element exists if the element is created by

doesn't work for me.

Answer Source

$('elemId').length doesn't work for me.

You need to put # before element id:


With vanilla JavaScript, you don't need the hash (#) e.g. document.getElementById('id_here') , however when using jQuery, you do need to put hash to target elements based on id just like CSS.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download