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

How to use javascript

coldplay.xixi
Release: 2023-01-04 09:35:12
Original
9680 people have browsed it

Methods to use javascript: 1. It can be introduced using script tags; 2. It can be embedded using script tags; 3. It can be bound in tag events; 4. It can be executed within a link; 5. It can be used in the address bar Enter the script to run.

How to use javascript

The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, DELL G3 computer.

How to use javascript:

1. You can use the script tag to introduce

<script type="text/javascript" src="js文件路径"></script>
Copy after login

2. You can use the script tag to embed

<script type="text/javascript" >
//js语句
</script>
Copy after login

3. You can bind the tag event

<div style="width:100px;height:100px;background:#ffaacc" onclick="alert(&#39;您点击了我&#39;)"></div>
Copy after login

4. You can execute it within the link

<a href="javascript:void(alert(&#39;我不走&#39;))">点我</a>
Copy after login

5. You can enter the script in the address bar to run

Enter # in the address bar ##

javascript:document.innerHTML=&#39;&#39;
Copy after login
Related free learning recommendations:

javascript video tutorial

The above is the detailed content of How to use 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