appendChild()





js/script.js
  • function funMake() {
  •  document.getElementById('d1').appendChild(document.createElement('p')).innerHTML = 'Hello World!';
  •  document.getElementById('d1').appendChild(document.createElement('h4')).innerHTML = 'Привет Мир!';
  •  document.getElementById('d1').appendChild(document.createElement('div')).innerHTML = 'To be or not to be?';
  • }
  • function funMake() {
  •  document.getElementById('d1').appendChild(document.createElement('p')).innerHTML = 'Hello World!';
  •  document.getElementById('d1').appendChild(document.createElement('h4')).innerHTML = 'Привет Мир!';
  •  document.getElementById('d1').appendChild(document.createElement('div')).innerHTML = 'To be or not to be?';
  • }


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"></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"></div>
  •  <script>
  •   funMake();
  •  </script>
  • </body>
  • </html>