JavaScript Introduction Video


Here is some code from a YouTube video on JavaScript. The video is called JavaScript Introduction and Basic Demo – Learn JavaScript Basics Tutorial (Part 1) given by Michael at the YouTube channel Learn Coding Tutorials. All you have to do to test this code is to copy it into a text editor, save it as an html file and open it in your browser. It will say Hello! at the top. When you click the word Hello! it will change to Goodbye. When you click Goodbye it will change back to Hello!

<!DOCTYPE html>
<html>
  <head>
  	<style>
  		body { background: black; 
  		}
  		div {
  			color: white;
  			font-size: 100px;
  			text-align: center;
  		}
  	</style>
  </head>

  <body>
  	 <div id="hello-world">Hello!</div> 
  </body>

  <script>
    var helloWorldElement = document.getElementById('hello-world');

    helloWorldElement.addEventListener('click', function() {
       if (helloWorldElement.innerHTML === 'Hello!'){
       	helloWorldElement.innerHTML = 'Goodbye.';
       } else {
          helloWorldElement.innerHTML = 'Hello!'
       }
    });
  </script>
</html>

There are other videos in this series as well as this one. Learn JavaScript Basics Tutorial (Part 2) – Primitive Data Types. JavaScript Arrays and Array Methods – Learn JavaScript Basics Tutorial (Part 3). JavaScript Objects – Learn JavaScript Basics Tutorial (Part 4). JavaScript Variables and Functions – Learn JavaScript Basics Tutorial (Part 5).

Leave a comment

Your email address will not be published. Required fields are marked *