Home » Check if element Exists on the Page using jQuery

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.

Read Also:  Laravel Clear Cache Using Artisan Command (CLI)

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.

Read Also:  jQuery Check if element exists or not

<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 :

Read Also:  Vuejs check if Element Exists Example


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 infinityknow.com 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.

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Top 10 Greatest US Latest Technology Products
  2. Read Also:  Laravel MySQL Advanced Query Techniques with Example
  3. Read Also:  Laravel 6 Guzzle HTTP Client Request Example
  4. Read Also:  jQuery AJAX Inline CRUD using Laravel MySQL
  5. Read Also:  sticky Scroll Back to Top Button using jQuery and CSS
  6. Read Also:  Server side Laravel DataTables example
  7. Read Also:  jQuery check if an element is exists in dom
  8. Read Also:  How to Check If an Element Exists in jQuery?
  9. Read Also:  Vuejs Editable Grid component - GridView in Vue.JS
  10. Read Also:  Laravel Google Maps Geocoding Example

Leave a Comment

Your email address will not be published. Required fields are marked *