Check if element Exists on the Page using jQuery

Today, We want to share with you Check if element Exists on the Page using jQuery.In this post we will show you Check For an Element on the Page with jQuery, hear for How to check if an element exists in jQuery we will give you demo and example for implement.In this post, we will learn about How to check a selector matches some content using jQuery? with an example.

Check if element Exists on the Page using jQuery

There are the Following The simple About jquery check if div exists by class Full Information With Example and source code.

As I will cover this Post with live Working example to develop jquery if element does not exist, so the jquery check if element exists in array is used for this example is following below.

jQuery length example

using jquery Example

if ($('#contact-form').length > 0) {
// do some source code that only applies to the contact form


simple you can use the .length property to check if an element exists.

<title>you can use the .length property to check if an element exists.</title>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>


<h1>jQuery check if an element exists</h1>

<script type="text/javascript">


    $("#contact1").click(function () {
			alert("contact1 exists");
			alert("contact1 does not exists");

    $("#contact2").click(function () {
			alert("contact2 exists");
			alert("contact2 does not exists");

<div id="contact1">
	<b>This is contact element which has an ide of "contact1"</b>


<input type='button' value='contact1 exists?' id='contact1'>
<input type='button' value='contact2 exists?' id='contact2'>


Web Programming Tutorials Example with Demo

Read :


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

I hope you get an idea about check if element exists javascript.
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.