Home > Web Front-end > JS Tutorial > body text

What are the three ways to introduce javascript?

青灯夜游
Release: 2023-01-06 11:17:44
Original
16022 people have browsed it

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>
Copy after login

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>
Copy after login

Three types: Inline introduction

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

[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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!