3

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>
0

1 Answer 1

4

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.