jQuery to determine whether an element exists on the page

1. Solution: judge according to the length of the obtained element

2. Examples:

 
 
 
 
if($("#content").length>0){
//do something
}

3. Illegal spelling

if($("#content")){
//do something
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324463322&siteId=291194637