感觉好久没来更博了,接下来就是关于HTML5中的JS部分喽~

1.在页面中显示HelloWorld

2.在页面中循环显示HelloWorld


1.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <!--js练习1-->
    <title>页面显示Hello World</title>
    <script type="text/javascript">
        //实现页面加载helloworld
        //js中单引号和双引号通用
        document.write('HelloWorld');
    </script>
</head>
<body>

</body>
</html>

2.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>循环输出HellWorld</title>
    <script>
        document.write('使用JavaScript循环打印HellWorld');
        for(var i=0;i<5;i++){
            document.write('<h3>HelloWorld</h3>');
        }
        document.write('<h1>HelloWorld</h1>')
    </script>
</head>
<body>
    文档主体内容
</body>
</html>
JavaScript语法基础

相关文章: