How to know whether an element existed with jQuery

For the reference. In general javascript we can check for the existence of an element using the method below:

In jQuery there is a simple approach to do the same check:

Moreover, if you want to know whether one or more <img /> tag or <p> tags exist inside an element by given id, you can do it same way. For example,


Thats it!

Leave a Reply