当前位置:网站首页>JS event binding and common events
JS event binding and common events
2022-06-27 17:36:00 【aqzengkuasheng】
Events can be JavaScript Detected behavior .Js The sending of events can be detected by itself , But if you don't deal with it, it won't work .
Event binding :
- HTML Inline properties : HTML Fill in the event related attributes directly in the element , The property value is JavaScript Code , When this event is triggered , Execute the contents of the attribute value
<button onclick="alert(' You click this button ');"> Click this button </button>
onclick Property indicates the trigger click, The content of the property value (JavaScript Code ) When you click the HTML Node .
2.Dom Event model binding
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<h1> Hello </h1>
<button onclick="alert(' You click this button ');"> Click this button </button>
<button id="btn"> Click another button </button>
<script>
var btn1=document.getElementById("btn");
btn1.onclick=function(){
console.log(" Another button helloWorld");
}
</script>
</body>
</html>
Common events 
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<h1> Hello </h1>
<button onclick="alert(' You click this button ');"> Click this button </button>
<button id="btn"> Click another button </button>
<script>
var btn1=document.getElementById("btn");
btn1.onclick=function(){
console.log(" Another button helloWorld");
}
</script>
</body>
</html>
window.onkeydown=function(event){
// When the event occurred , It can be used event Represents the object of the event
console.log(event)
}
This indicates a keyboard event :
边栏推荐
- Leetcode 46 Full Permutation
- Deeply digitise, lead cloud nativity and serve more developers
- [leetcode] 2. Add two numbers (user-defined listnode), medium
- Part 32 supplement (32) string of ECMAScript
- Uploading multiple attachments from canvas apps to SharePoint
- d3dx9_ How to repair 40.dll? Win10 system d3dx9_ What if 40.dll is lost?
- Jeesite 4.0 replaces the default view style and customizes the theme
- 软件测试基础-软件测试历史流程,分类,好处,限制
- Unity 阴影——阴影平坠(Shadow pancaking)
- The time of localdatetime type (2019-11-19t15:16:17) is queried with the time range of Oracle
猜你喜欢
![[qt learning notes]qt uses MFC compilation to generate DLL libraries. The problem that DLL cannot be loaded occurs on computers without programming environment](/img/fb/4cf7013687973a7214e51faf3358c0.jpg)
[qt learning notes]qt uses MFC compilation to generate DLL libraries. The problem that DLL cannot be loaded occurs on computers without programming environment

当发布/订阅模式遇上.NET

10 minutes to master the installation steps of MySQL

Ping An technology's practice of migrating from Oracle to ubisql

Software testing Basics - software testing history, process, classification, benefits, limitations

428-二叉树(501.二叉搜索树中的众数、701.二叉搜索树中的插入操作、450.删除二叉搜索树中的节点、669. 修剪二叉搜索树)

EMQ helps Qingdao Yanbo build a smart water platform

2022年中国音频市场年度综合分析

2022 Liaoning's latest eight members (Safety Officer) simulated test question bank and answers

d3dx9_ How to repair 33.dll? d3dx9_ What if 33.dll is lost?
随机推荐
The time of localdatetime type (2019-11-19t15:16:17) is queried with the time range of Oracle
P4251 [scoi2015] small convex play matrix (still a little confused)
leetcode 200. Number of islands
d3dx9_ How to repair 33.dll? d3dx9_ What if 33.dll is lost?
Under the influence of external factors, how to manage internal resources and reduce costs is the key
Popularization of MCU IO port: detailed explanation of push-pull output and open drain output
[JS reverse hundreds of examples] I love to solve 2022 Spring Festival problems and receive red envelopes
d3dx9_ How to repair 32.dll? d3dx9_ Solution to 32.dll missing
Leetcode 46 Full Permutation
EMQ helps Qingdao Yanbo build a smart water platform
Ti Click: quickly set up tidb online laboratory through browser | ti- team interview can be conducted immediately
Part 30 supplement (30) ECMAScript object
WOx WPM installing the Youdao plug-in
Oracle concept II
All you want to know about large screen visualization is here
d3dx9_ How to repair 40.dll? Win10 system d3dx9_ What if 40.dll is lost?
如何提升IT电子设备效能管理
National food safety risk assessment center: do not blindly and unilaterally pursue "zero addition" and "pure natural" food
d3dx9_ Where is 35.dll? d3dx9_ Where can I download 35.dll
(5) SPI application design and simulation verification 3 - verification code implementation