Trong trang HTML, thường dùng type="text/javascript" trong thẻ <script>.
Ví dụ:
<script type="text/javascript"> </script>
Tuy nhiên HTML5 mang来改进. JavaScript trở thành ngôn ngữ mặc định cho HTML5 và trình duyệt hiện đại. Do đó, giờ không cần thêm type="text/javascript" trong <script>.
<script> </script>
Ví dụ
Ví dụ jQuery.
Demo trực tiếp
<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>