From the course: HTML for Programmers
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Working with JavaScript
From the course: HTML for Programmers
Working with JavaScript
- [Instructor] JavaScript is the programming language that lets us add functionality to our web pages. There are two ways to include JavaScript in our HTML pages. The first way is with Embedded JavaScript. For this, we declare a script element at the end of the HTML page above the closing html tag. We can then write our JavaScript code within the script element. Here we've declared a user alert function at the end of the HTML file between two script tags. The second way to work with JavaScript is by linking to an external script. We do this by declaring a script element at the end of the HTML page, but add a source attribute. The value of this attribute is the link to the external script file. Here we have a script tag, but instead of writing our JavaScript code in this file, we've included a link to our index.js file. Similar to the CSS discussion, there are some opinions around which method is preferred. While both…