jQuery two common ways to verify that an element is empty

  • 2020-05-16 06:24:45
  • OfStack

This article illustrates two common ways that jQuery can verify that an element is empty. Share with you for your reference. The details are as follows:

Two methods are provided below to check if the content of the element specifying id is empty


//  methods 1
if (!$('#jb51').html()) {
////www.ofstack.com  nothing ;
}

//  methods 2
if ($('#jb51').is(":empty")) {
////www.ofstack.com  nothing ;
}

I hope this article is helpful for you to design jQuery program.


Related articles: