HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <p>Do p tag has a child?</p> <button onclick="myFunction()">Check Here</button> <script> var x = document.getElementsByTagName("p")[0]; function myFunction(){ alert(x.hasChildNodes()); } </script> <p><strong>Note:</strong> TextNode is also a child.</p> </body> </html>
OUTPUT
×

Save as Private