From the course: Vanilla JavaScript: Animations

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Writing JavaScript

Writing JavaScript - JavaScript Tutorial

From the course: Vanilla JavaScript: Animations

Start my 1-month free trial

Writing JavaScript

- We'll now write a little bit of JavaScript, within an external file and bind this to our HTML. Pretty simple stuff, but quite necessary to ensure that everything is working correctly. Let's insert a new line directly beneath the link tag that links to our style sheet, and we'll paste in a script tag. This has a source attribute that points to a file named "app.js". We then have to close out the script tag. This will include that JavaScript file, and any JavaScript within it. Similar to how we created our CSS in HTML documents, inside of our project folder we'll create a new file, and this time name it "app.js", and, within that file, we will go ahead and paste in some snippets. Alright, so let's paste in a little bit of JavaScript from our snippets file. And what this JavaScript is going to do is, it's going to invoke the document itself. "Get element by ID" is going to return a reference to a specific element, in this case, an element with the ID of "msg" or message. We're then…

Contents