当前位置:网站首页>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 92. Reverse linked list II
- How to modify / display GPIO status through ADB shell
- Solving Poisson equation by tensorflow
- Hospital reservation and registration system - system structure
- A robot is located in the upper left corner of an M x n grid. The robot can only move down or right one step at a time. The robot attempts to reach the lower right corner of the grid. How many differe
- 1. introduction to MariaDB
- Byte + Google super full kotlin learning King fried notes! Kotlin introductory tutorial + Advanced kotlin enhanced actual combat (with demo)
- Autodesk NavisWorks 2022 software installation package download and installation tutorial
- About how vs2019c # establishes the login interface, the user name and password entered must match the records in the access database
猜你喜欢

EMQ helps Qingdao Yanbo build a smart water platform

Annual comprehensive analysis of China's audio market in 2022

After the mobile phone, it was reported that Samsung also cut the output of TV and other home appliance product lines
![[Niuke's questions] nowcoder claims to have remembered all Fibonacci numbers between 1 and 100000. To test him, we gave him a random number N and asked him to say the nth Fibonacci number. If the nth](/img/70/fa79ba38e28c41ed28bce2ec73cd79.png)
[Niuke's questions] nowcoder claims to have remembered all Fibonacci numbers between 1 and 100000. To test him, we gave him a random number N and asked him to say the nth Fibonacci number. If the nth

Kubernetes基础自学系列 | Ingress API讲解

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

Hospital reservation and registration system - system structure

Electronic smart package tutorial

Leetcode 5. Longest Palindromic Substring

医院预约挂号系统-系统结构
随机推荐
About how vs2019c # establishes the login interface, the user name and password entered must match the records in the access database
黑马程序员-软件测试基础班-02-30-45工具代开浏览器运行代码,音、视频、测试点,音视频标签,布局标签。超链接语法进阶,绝对路径,相对路径
tensorflow求解泊松方程
Byte + Google super full kotlin learning King fried notes! Kotlin introductory tutorial + Advanced kotlin enhanced actual combat (with demo)
After the mobile phone, it was reported that Samsung also cut the output of TV and other home appliance product lines
10分钟掌握mysql的安装步骤
Cesium realizes satellite orbit detour
C语言教师工作量管理系统
Kubernetes basic self-study series | introduction to ingress API
A robot is located in the upper left corner of an M x n grid. The robot can only move down or right one step at a time. The robot attempts to reach the lower right corner of the grid. How many differe
Oracle TRUNC function processing date format
What is RPC
Anfulai embedded weekly report (issue 252): February 7, 2022 to February 13, 2022
[qt learning notes]qt uses MFC compilation to generate DLL libraries. The problem that DLL cannot be loaded occurs on computers without programming environment
Oracle概念二
Performance problems caused by redis cache invalidation and competitive loading
Oracle concept 3
如何提升IT电子设备效能管理
Uploading multiple attachments from canvas apps to SharePoint
Jeesite 4.0 replaces the default view style and customizes the theme