当前位置:网站首页>2、 Three ways to write JS code
2、 Three ways to write JS code
2022-06-13 08:33:00 【001128XY】
Write JS Three ways to code
1、 Inline
Format :
<button onclick="alert('hello js');"> Am I </button>
2、 Inside JS( In page )
Format :
<!-- type="text/javascript" Indicates that the type of script you write is JS -->
<!-- If you don't write , The default is type="text/javascript" -->
<script type="text/javascript"> alert("hello js"); </script>
Be careful : Advice on body Bottom , Because the code is executed from top to bottom , stay head The label says JS Code can't get body The elements of the label , If you want to write in front , Think again HTML Elements in can be used window.onload.
3、 external JS( Outer chain )
Format :
<script type="text/javascript" src="out.js"></script>
Be careful : Outer chain script You cannot write in a code block js Code , Even if it's written, it won't execute ;
<script type="text/javascript" src="out.js"> alert("helo js~"); // Will not be executed </script>
边栏推荐
- Wrap dynamically created child elements in dynamically created structures
- How to modify desktop path in win10 system
- 淘宝商品历史价格接口/商品历史价走势接口代码对接分享
- 使用kvm创建三台能通局域网的虚拟机
- Explanation of JS event loop mechanism and asynchronous tasks
- Logstash failed to create queue
- 关于redis使用分布式锁的封装工具类
- CCNP_ BT static routing
- JS - array de duplication in the array object case
- Set implements list search and exclusion
猜你喜欢
How does the BD new tab plug-in log in?
How to download and install stm32cubemx
Svg text stroke effect
The method of SolidWorks modifying text font in engineering drawing
第115页的gtk+编程例子——最简单的进度条2附带使用Anjuta写gtk程序的步骤
JS array using the reduce() method
redis. exceptions. ConnectionError: Error 111 connecting to 172.16.8.128:6379. Connection refused.
学习记录4: einops // cudnn.benchamark=true // hook
Format_ String_ Server
1.SolidWorks各模块的学习顺序
随机推荐
JS - array de duplication in the array object case
Data accuracy problems caused by inconsistent data types during sum in MySQL
CCNP_ Bt-ospf big experiment (1)
Reverse order and comparison of strings
[virt-manager]远程管理启动虚拟机时,鼠标飘逸的问题
Logstash configuration reference article
d3.js&nvd3. JS - how to set the y-axis range - d3 js & nvd3. js — How to set y-axis range
[pychart pit stepping record] prompt after configuring remote operation, [errno 2] no such file or directory
The method of SolidWorks modifying text font in engineering drawing
About redis encapsulation tool class using distributed locks
Request alarm: refer policy: strict origin when cross origin or reference site policy: no refer when downgrade
[game theory complete information static game] Application of Nash equilibrium
Journal d'acquisition du faisceau de fichiers à Elk
字符串的逆序与比较
Vs installation of vassistx plug-in causes Chinese input of wpf-xaml file to be garbled. Solution
ERP basic data Huaxia
Dest0g3 520 orientation
淘宝商品销量接口/淘宝商品销量监控接口/商品累计销量接口
HCIP_ MGRE comprehensive experiment
VS安装VAssistX插件导致WPF-XAML文件输入中文出现乱码问题解决方案