How to Check If an Element Exists in jQuery?

Rate this post

Question: How do you check if an element exists or not in jQuery? In jQuery Example, We can use the simple . length property (Count a total number of the matched HTML DOM elements) to check if an element exists or not?.

You can use the Simple CDN Of the jQuery .length property to check whether HTML an element exists or not in phase if you want to trigger some jquery event only if a specific Data element verify exist in HTML DOM. also You can learn All about HTML Dom Check some property

Read Also:  jquery check if element exists
jquery check if element exists,jquery check if element exists in dom,jquery check if element exists in array,jquery if element does not exist,jquery check if dynamic element exists,jquery check if element exists stackoverflow,check if element exists javascript,jquery check if div exists by class,jquery if element exists by id,jquery check if element exists
jquery check if element exist

let’s start to learn an example below that shown an alert on button trigger if the each data element exist or not.

You need to included # before HTML element id or also you can alternative way to use check if div exist by class, ID, Tag, jquery if element exist or not Like as a below Example


Example : Check if element exist in jQuery

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title> - jQuery Test Element Exist or Not</title>
<script src=""></script>
            alert("The virat kohali Team India is present.");
    <div id="player_info"></div>    
    <p>Virat Kohli is great an international player who currently Cool captains the India national Cricket team.</p>
    <button>get Information</button>

Free Live Chat for Any Issue
Web Programming Tutorials Example with Demo

Read :

Read Also:  how to hide div when click outside using jquery?


You can also read about AngularJS, ASP.NET, VueJs, PHP.


I hope you get an idea about jquery check if element exist.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.