check if an element has children code example Example: check if an HTML element has any children if (element.hasChildNodes()) { // It has at least one }