How to Use JS programs:
Scripts can be written anywhere in hmtl or JSP.
1. <SCRIPT> JS Program </SCRIPT>. Several <JavaScript> </JavaScript> On the same page are interconnected, rather than independent, and variables can access each other. Like java code snippets in JSP.
2. <a href = "javascript: JS program"> demo </a>: You can write any JS program after the colon. To keep it clean, you can put it in a function. The execution time is when you click the link. The same is true for form <form action = "javascript: JS program">.
3. When an event occurs. Every tag has an event. when an event occurs, it can trigger JS programs, such as onclick = "JS program ".
4. Reference an external file <*. js>. <SCRIPT src = ""> </SCRIPT> When referencing the file. The file can be imported anywhere, usually at the head of the header. <*. Js> file, you do not need to write <SCRIPT> </SCRIPT> .. You can load multiple JS source programs, but pay attention to the sequence.
The program runs sequentially from top to bottom. If an error occurs, the subsequent tasks cannot be run.