Home > Web Front-end > Front-end Q&A > What are the three ways to use javascript?

What are the three ways to use javascript?

青灯夜游
Release: 2021-10-28 17:03:31
Original
3124 people have browsed it

Method: 1. Use it in the event attribute of the tag, the syntax ""; 2. Write it in the script tag pair, the syntax ""; 3. Use the "" statement.

What are the three ways to use javascript?

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

The usage of js is similar to css:

1. Inline

Use "";

<body onload="alert(&#39;hello world3&#39;)";>
</body>
Copy after login
## in the label attribute

#2. Embedded

Use script tag directly

<script>
alert("hello world2");
</script>
Copy after login

3. Linked

Use
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template