您的

在 HTML 页面中,<script> 标签中主要使用 text/javascript。

这里有一个例子

<script type="text/javascript">
</script>

但是,HTML5 的引入带来了一些新的改进。JavaScript 成为 HTML5 和现代浏览器的默认语言。因此,现在不需要在 <script> 标签中添加 text/javascript。

<script>
</script>

示例

让我们看一个 jQuery 中的示例。

<html>
   <head>
      <title> jQuery Example</title>
      <script src = “https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
      <script>
         $(document).ready(function(){
            document.write("Hello, World!");
         });
      </script>
   </head>
   <body>
      <h1>Hello</h1>
   </body>
</html>

相关文章