So on W3Schools they show this example:
<p id="demo">A Paragraph</p>
<button type="button" onclick="myFunction()">Try it</button>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Paragraph changed.";
}
</script>
If I had an external JS File called myJSFile.js and all it had was
function myFunction(id) {
document.getElementById(id).innerHTML = "Paragraph changed.";
}
and I wanted to pass the ID "demo" from the HTML into the .js file how would I do it? I know you start with
<script src = "myJSFile.js></script>
but I don't know how to call the myFunction function and pass an argument into it.
To be extra clear I want to do something like
<head>
<script src = "myJSFile.js></script>
</head>
<body>
...
<p id = "demo></demo>
myFunction("demo")
</body>