Home  >  Article  >  Web Front-end  >  How to use javascript

How to use javascript

coldplay.xixi
coldplay.xixiOriginal
2021-04-08 14:24:509663browse

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>

2. You can use the script tag to embed

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

3. You can bind the tag event

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

4. You can execute it within the link

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

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

Enter # in the address bar ##

javascript:document.innerHTML=&#39;&#39;

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!

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