Introduction to JavaScript
1. Definition : JavaScript is a scripting language and requires a host file. Its host file is an html file.
JavaScript is a lightweight programming language.
JavaScript is programming code that can be inserted into HTML pages.
JavaScript can be executed by all modern browsers after inserting an HTML page.
2. Usage :
There are three positions in the html:
1) Inside the head;
2) Inside the body;
3) After</html>, it is generally written after</html> for the sake of safety. <script language="javascript">code must be placed here</script>.
1. Write html output
2. Respond to events
3. Find elements and change content/style
4. Define variable group--equivalent to structure (set of variables) in C#
<script> code can be written in <head> or after </html>. But the connection <input> submitted by the button must be written in <body>.
5. How to call external JS
Use "File"--create "JavaScript"--"Create". Write operations, functions, etc. in the newly created "JavaScript" and call them in the html.
Format: <script src="path.JS "></script>
Create a new file with Js as the suffix externally.
Reference external Js in host file html