program1.php
<html> <header> <script>
function myFunction(p1, p2) {
return p1 * p2;
}
document.getElementById("demo").innerHTML = myFunction(4, 3);
</script> </header> <body> <div id="demo"></div> </body> </html>
I don't understand why the above code does not show any value?
and why this one does?
program2.php
<html> <body> <div id="demo"></div> <script>
function myFunction(p1, p2) {
return p1 * p2;
}
document.getElementById("demo").innerHTML = myFunction(4, 3);
</script> </body> </html>
Why I cannot stated the js first then calling it? Why calling it first then stated the js?