当前位置:网站首页>js中的事件
js中的事件
2022-06-30 00:00:00 【山岚~】
- index.html
<!DOCTYPE html>
<html lang = "en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="/css/index.css">
<title> myFirstWeb</title>
</head>
<body>
<p>
hello world!
</p>
<script type="module"> import {
main } from "/js/index.js"; main(); </script>
<div></div>
</body>
</html>
href中的路径可以修改;
from中的路径也可以修改;
- index.css
div{
width: 300px;
height : 300px;
background-color: rgb(95, 148, 165);
}
- index.js
let div = document.querySelector('div');
function main()
{
}
export{
main
}
效果图:
文件结构图:
第二个, 事件的测定
:
<!DOCTYPE html>
<html lang = "en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="/css/index.css">
<title> myFirstWeb</title>
</head>
<body>
<p>
hello world!
</p>
<script type="module"> import {
main } from "/js/index.js"; main(); </script>
<div tabindex="0"></div>
<input type="text">
</body>
</html>
div{
width: 300px;
height : 300px;
background-color: rgb(95, 148, 165);
}
let div = document.querySelector('div');
let input = document.querySelector('input');
function main()
{
div.addEventListener('mousedown', function(event)
{
console.log(event.type , event.button);
})
div.addEventListener('mouseup', function(event)
{
console.log(event.type , event.button);
})
input.addEventListener('keydown', function(event)
{
console.log(event.type, event.code , event.shiftKey, event.ctrlKey , event.altKey);
})
window.addEventListener('resize', function(e)
{
console.log(e.type)
}
}
export{
main
}
边栏推荐
猜你喜欢

6.29日刷题题解

Root cause of glideexception: failed decodepath{directbytebuffer- > gifdrawable- > drawable}

Inspiration collection · evaluation of creative writing software: flomo, obsidian memo, napkin, flowus

QT learning 07 coordinate system in QT

架构实战营模块5作业

JVM之栈空间

Basic operations such as MySQL startup under Windows platform

视频ToneMapping(HDR转SDR)中的颜色空间转换问题(BT2020转BT709,YCbCr、YUV和RGB)

Machine learning: the concept and application of VC dimension

西门子低代码 9.14版本: 满足不同需求
随机推荐
Do mysqlcdc data not support windowing functions like row_ Number, lead
[rust weekly library] Tokei - a utility for statistics of code lines and other information
QT learning 06 widgets and window types
Solr基础操作9
Set up security groups, record domain names, and apply for SSL certificates
QT learning 07 coordinate system in QT
I wonder if I can open an account today? In addition, is it safe to open an account online now?
Solr基础操作8
Unity splashimage scaling problem
Sword finger offer 14- I. cut rope
Simple understanding of B tree and b+ tree
视频ToneMapping(HDR转SDR)中的颜色空间转换问题(BT2020转BT709,YCbCr、YUV和RGB)
Halcon practical: design idea of solder joint detection
Table responsive layout tips for super nice
MySQL multi table query
FPGA Development (1) -- serial port communication
Solr basic operations 7
Embedded development: Hardware in the loop testing
Zhongang Mining: Fluorite helps the construction and development of lithium battery in fluorine industry
Label Troubleshooting: unable to open the marked image

