Check if element exists in jQuery

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

You need to put # before element id:

$('#elemId').length
---^

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)