Home Javascript How to Check if Element is Exists or not in jQuery?

How to Check if Element is Exists or not in jQuery?

by Shahriar Sagor
Element is Exists or not

Today now in this post i will show you How to Check if Element is Exists or not in jQuery? Most of the time you have need to check specific element is exists or not in javascript. We know jquery provide us a length() method that can help us to check the element is exists or not. If you are new and if you want to do this then let’s start and see the bellow example:

Example:

<script type="text/javascript">
	$(document).ready(function(){  
	   if ($('.image').length) {   
	      console.log('yes, Image class is exists.');  
	   } else {  
	      console.log('sorry, Image class is not exists.');  
	   }
	});
</script>

Read Also : How to convert Object into Array in PHP?

Thanks for read. I hope it help you. For more you can follow us on facebook.

close

You may also like