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

By Hardik Savani September 5, 2020 Category : Javascript jQuery

Most of the time we require to check specific element is exists or not in javascript. but jquery provide length() method that can help to check element is exists or not. If you are new and want to do this then see 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>

We are Recommending you