In Jquery,When we use dynamic elements then sometimes you need to check whether elements exits or not before perform a certain action to element.

How to check if an element exists or not in Jquery

This case ,you can use the .length property of jquery to check if an element exists or not. if the element exists, the length property will return the total number of the matched elements.

As  example:-

Explanation of above example:-

==>There is a div ,where we have given id(checkdiv) to track the particular div.See below example also for more overview.




==>We used .length to find matched elements in html.

jQuery length example with the use html :-

Check BELOW live demo for above example:-


Try demo by this link