[英]Calling a java script function inside HTML
I am trying to print something inside my html from a java script. 我正在尝试通过Java脚本在html中打印一些内容。 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>
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 您正在发布的示例中尚未定义您的函数,因此call go有效地什么也没做,更改了脚本标签的顺序
<!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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.