Friday, September 4, 2015

How to detect if a jQuery selector returns null?

if ( $("#test").length ) {
  alert("element(s) found")
} 
else {
  alert("nothing found")
}

No comments: