HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <p>First click on "Check" button and then click on "Connect Node" button and then "check" button to see the difference.</p> <button onclick="check()">Check</button> <button onclick="connectNode()">Connect Node</button> <script> var node = document.createElement('p'); var text = document.createTextNode("Hello There"); node.appendChild(text); function check(){ if(node.isConnected) alert("<p> tag is connected"); else alert("<p> tag is NOT connected"); } function connectNode(){ document.body.appendChild(node); } </script> </body> </html>
OUTPUT
×

Save as Private