HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <ul><li>Honda</li><li>Yamaha</li></ul> <button onclick="myFunction()">Remove Child</button> <script> var x = document.getElementsByTagName("ul")[0]; function myFunction(){ if(x.hasChildNodes()) x.removeChild(x.childNodes[0]); else alert("No child found in ul tag"); } </script> <p><strong>Note:</strong> LineBreak is also a child.</p> </body> </html>
OUTPUT
×

Save as Private