This series of js summary involves almost all the knowledge points of js from the basics to the difficult points. If there are any inaccuracies, please correct me. Thank you
1. Inline introduction (not recommended, security performance is very low)
<div onclick='alert(11)'></div>
2. Embedded (will The js code is written between script script blocks)
<script type='text/javascript'>alert(11)</script>
3. External link (write the js code in an external file and find the import through src)
<script src='js/index.js' type='text/javascript'></script>
Details:
1. In the outer link, in the middle of the script block You cannot write js code, and even if you write it, it will not be executed.
2. We usually put js at the end of the body. The reason is that html pages are loaded sequentially from top to bottom. js usually obtains html notes to give dynamic operation effects. So we need to load the html tag first before loading our js
The above is the detailed content of What are the ways to introduce javascript into the page?. For more information, please follow other related articles on the PHP Chinese website!