My first line of js code

Create a new text document JsFirstDemo


1674835-17c83f704b0bf929.png
Pictures .png

Open the Edit and enter the following code

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>hello javascript</title>
</head>
<body>
<script language="javascript">
alert("I want you!");
</script>
</body>
</html>
1674835-3de9825b59020493.png
Pictures .png

Save and exit
then change the file extension .html


1674835-22467f0241cab727.png
Pictures .png

Now that we have completed


1674835-12d77d7c65368d80.png
Pictures .png

Next we choose a browser to open the file
1674835-4e8c3d5c3a15463d.png
Pictures .png

The contents of the page that appears is what we have just written content

Above, we are in 页面中直接嵌入JavaScript代码
the next us 链接外部的JavaScript文件to achieve

Also new text document function, and .html files in the same path


1674835-9aaf0f937a0c78db.png
Pictures .png

Open the file and enter the following code function

1674835-db94c8169b764c1a.png
Pictures .png

Save and exit
the function suffix to .js


1674835-8cbc1e282978bb9f.png
Pictures .png

like this


1674835-73ece22f255e5459.png
Pictures .png

Modify the code following JsFirstDemo.html
1674835-f7dff9bf92e30b2a.png
Pictures .png

Save and exit
and then file browser to open JsFirstDemo.html
1674835-10551ca3e5490ed4.png
Pictures .png

After closing the box shells


1674835-08949da9823f9f0b.png
Pictures .png

Reproduced in: https: //www.jianshu.com/p/d5bbafadcff9

Guess you like

Origin blog.csdn.net/weixin_34115824/article/details/91106621