August 29 2016

Jquery find the specific Id if exists

Tagged Under :

javascript
If want to check the specific Id already exists inside the site. you may using “length” to do it.

For Example:
if( $('#selector').length) {
     // it exists
}
if the length more then 0, that’s mean the following Id already exists inside the site.

if you are using class to check
if( $('.selector').length) {
     // it exists
}

Make a Comment

*

code