calling a js function in html code example

Example 1: call js script in html

<script src="file1.js" type="text/javascript"></script> 
<script src="file2.js" type="text/javascript"></script>

Example 2: running a function in a function javascript

function runFunction() {
  myFunction();
}

function myFunction() {
  alert("runFunction made me run");
}

runFunction();

Example 3: call function javascript

// Define your function
function sayHello(msg){
	console.log("Hello, " + msg);
}

// Call it
sayHello("Norris");

// outputs:
// Hello, Norris

Tags:

Html Example