" statement; 2. Embed js code inside the script tag pair; 3. In the onclick attribute of the HTML tag Write js code."/> " statement; 2. Embed js code inside the script tag pair; 3. In the onclick attribute of the HTML tag Write js code.">

Home  >  Article  >  Web Front-end  >  What are the three ways to introduce javascript?

What are the three ways to introduce javascript?

青灯夜游
青灯夜游Original
2021-06-17 17:09:5216013browse

Method: 1. Use the "" statement; 2. Embed js code inside the script tag pair; 3. Write js code in the onclick attribute of the HTML tag.

What are the three ways to introduce javascript?

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

JavaScript is a high-level scripting language that belongs to the Internet. It has been widely used in Web application development. It is often used to add various dynamic functions to web pages and provide users with smoother and more beautiful browsing effects. Usually JavaScript scripts realize their functions by embedding them in HTML.

Three ways to introduce javascript:

The first one: external introduction

<script type="text/javascript" src="路径/文件名.js"></script>

If a js file is imported from outside the script tag, no more js programs can be written in this tag

Second: Internal introduction

<script type="text/javascript">
//js代码
alert(&#39;js hello world!&#39;);//弹窗
</script>

Three types: Inline introduction

<input type="button" value="行内引入方式" onclick="javascript:alert(&#39;我是行内引入方式&#39;);">

[Related recommendations: javascript learning tutorial]

The above is the detailed content of What are the three ways to introduce javascript?. 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