We can connect JavaScript to HTML documents in a couple of ways:
- Embedding it with the
- Linking a separate JavaScript file to the HTML document
External file: myScript.js
function myFunction() {
document.getElementById("demo").innerHTML = "Paragraph changed.";
}
<!DOCTYPE html>