Home  >  Article  >  Web Front-end  >  How to use html script tag

How to use html script tag

藏色散人
藏色散人Original
2019-05-27 15:07:303158browse

html script tag is used to define client-side scripts, such as JavaScript. The script element can contain script statements or point to external script files through the src attribute.

How to use html script tag

#How to use the html script tag?

Function: Used to define client-side scripts, such as JavaScript.

Note: The script element can either contain script statements or point to an external script file through the src attribute. The required type attribute specifies the MIME type of the script. Common applications of JavaScript are image manipulation, form validation, and dynamic content updates.

Note:

If the code inside this element is not located in a function, then the code will be executed immediately when the page is loaded. Scripts following the

tag will be ignored.

html script tag example 1

<html>
<body>
<script type="text/javascript">
document.write("<h1>Hello World!</h1>")
</script> 
</body>
</html>

Run result:

How to use html script tag

html script Tag example 2

<html>
<body>
<script type="text/javascript">
alert(&#39;hello php.cn&#39;);
</script> 
</body>
</html>

Running result:

How to use html script tag

The above is the detailed content of How to use html script tag. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to use html table tagNext article:How to use html table tag

Related articles

See more