Home >Web Front-end >JS Tutorial >Examples of using JavaScript code in HTML code_javascript tips
<script></script> tag
To use JavaScript in HTML, you need to use the <script></script> tag and define the type attribute value as text/javascript, as shown in the previous alert pop-up prompt box example:
Usually JavaScript code alone is meaningless. JavaScript code is generally used in conjunction with HTML code, because JavaScript was originally created to make up for the shortcomings of HTML. Here is an example of JavaScript code and HTML code used together:
Usually, JavaScript code (<script></script> tag) is placed within the
tag. For more details, please refer to "What is JavaScript code placed in HTML? place? 》.