Reputation: 314
I am trying to print something inside my html from a java script. I did this but it don't work:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>I am trying to print <script>go();</script></p>
<script>
function go() {
document.write("Hello World!");
}
</script>
</body>
</html>
Upvotes: 3
Views: 24402
Reputation: 3231
You're function hasn't been defined yet in the example you are posting, so call to go effectively does nothing, change the ordering of your script tag
<!DOCTYPE html>
<html>
<head>
<script>
function go() {
document.write("Hello World!");
}
</script>
</head>
<body>
<p>I am trying to print <script>go();</script></p>
</body>
</html>
Upvotes: 4