Is it correct to check the presence of an element in the DOM in this way:

$('#element').length; 

Or does jQuery have no difference at all?

    1 answer 1

    In short, yes.

     if ($(selector).length>0) { // Do something } 

    Read more .

    • Oh .... Merci! - ferrari