firstChild





js/script.js
  • function funMake() {
  •  document.write(document.getElementById('d1').firstChild.innerHTML + '<br />');
  •  document.write(document.getElementById('d1').firstChild.nextSibling.innerHTML);
  • }
  • function funMake() {
  •  document.write(document.getElementById('d1').firstChild.innerHTML + '<br />');
  •  document.write(document.getElementById('d1').firstChild.nextSibling.innerHTML);
  • }


index.html
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script src="js/script.js"></script>
  • </head>
  • <body>
  •  <div id="d1">
  •   <p>Hello World!</p>
  •   <p>Привет Мир!</p>
  •   <p>To be or not to be?</p>
  •  </div>
  •  <script>
  •   funMake();
  •  </script>
  • </body>
  • </html>
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script src="js/script.js"></script>
  • </head>
  • <body>
  •  <div id="d1">
  •   <p>Hello World!</p>
  •   <p>Привет Мир!</p>
  •   <p>To be or not to be?</p>
  •  </div>
  •  <script>
  •   funMake();
  •  </script>
  • </body>
  • </html>