当前位置:网站首页>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 :
边栏推荐
- Hospital reservation and registration system - system structure
- Drawing for example study of flashcc
- Dark horse programmer - software testing foundation class -02-30-45 tools open browser running code, audio, video, test points, audio and video labels, layout labels. Advanced hyperlink syntax, absolu
- SQLite net (SQLite is used by unity, WPF and WinForm)
- 阿里云刘珅孜:云游戏带来的启发——端上创新
- leetcode 92. Reverse linked list II
- 2022 Liaoning's latest eight members (Safety Officer) simulated test question bank and answers
- Software testing Basics - software testing history, process, classification, benefits, limitations
- Control file related views
- (POJ - 1847) tram (shortest circuit)
猜你喜欢
2022 Liaoning's latest eight members (Safety Officer) simulated test question bank and answers
[the way of programmer training] - 3 Character count statistics
Unity shadow shadow pancaking
Mihayou sued Minmetals trust, which was exposed to product thunderstorms
Sliding window + monotone queue concept and example (p1886 Logu)
Why should string be designed to be immutable?
模拟进程调度
09 route guard authenticates URL
10 minutes to master the installation steps of MySQL
Oracle TRUNC function processing date format
随机推荐
Control file related views
Why should string be designed to be immutable?
1. introduction to MariaDB
09 route guard authenticates URL
leetcode 70. climb stairs
Ten common methods of arrays tools
Use pyinstaller to package py files into exe. Precautions and error typeerror:_ get_ sysconfigdata_ name() missing 1...‘ check_ Solutions to exists'
Drawing for example study of flashcc
Awk determines whether the first column is greater than 1. If it is greater than 1, the row will be printed
Part 30 supplement (30) ECMAScript object
d3dx9_ How to repair 40.dll? Win10 system d3dx9_ What if 40.dll is lost?
2022 Liaoning latest fire facility operator simulation test question bank and answers
(POJ - 1847) tram (shortest circuit)
2022年中国音频市场年度综合分析
What do fast fashion brands care more about?
Explain the distributed computing of Apache skywalking OAP in detail
[leetcode] 2. Add two numbers (user-defined listnode), medium
2022 Liaoning's latest eight members (Safety Officer) simulated test question bank and answers
leetcode 69. Square root of X
Huawei cloud devcloud launched four new capabilities, setting two domestic firsts