YogeshChauhan . com

How to check if the element exists using JavaScript and jQuery?

in JavaScript & jQuery on September 11, 2020


if ($('#elementId').length > 0) {
  // element exists.


var el =  document.getElementById('elementId');
if (typeof(el) != 'undefined' && el != null)
  // element exists.



Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 How to Use SQL MAX() Function with Dates? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

Jun 16 What are Stored Procedures for SQL Server? Jun 16 What are Class Constants in PHP? Jun 15 A short basic guide on states in React Jun 15 How to define constants in PHP? Jun 15 How to define visibility for a property in PHP? Jun 15 How to use @if and @else in SCSS?

You might also like these

How to create a Horizontal Scroll on button click using JavaScript?JavaScriptDefault Values in SCSS (Sass)SCSSHow to calculate elapsed time in JavaScript?JavaScriptHow to remove trailing characters from a string using JavaScript?JavaScriptDebugging in WordPress Part 1: WP_DEBUGWordPressbin2hex() and chr() String Functions in PHPPHPapply_filters function in WordPressWordPressHow to add new elements with swing animation using JavaScript and CSS?CSSURL paths in DrupalDrupalKilling A Project Part 3: How can an organization ensure that a doomed project is killed as early as possible?MiscHow to retrieve homepage URL in WordPress?WordPressForcing the domain to serve securely using HTTPSMisc