63 lines
1.3 KiB
HTML
63 lines
1.3 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>事件</title>
|
||
</head>
|
||
|
||
<body>
|
||
|
||
<button class="demo">登 录</button>
|
||
|
||
</body>
|
||
<script>
|
||
// 事件:在网页上完成的操作
|
||
// 构成:
|
||
// 事件源 事件类型 事件处理函数
|
||
|
||
// 写法
|
||
// dom document
|
||
// var button = document.querySelector("button");
|
||
|
||
// button.onclick = function () {
|
||
// alert("点我干什么1??")
|
||
// }
|
||
|
||
|
||
// 方法的回调 (重点!!!等会提)
|
||
// button.addEventListener('click', function (){
|
||
// alert("点我干什么2??")
|
||
// } )
|
||
|
||
// button.addEventListener('click', function (){
|
||
// alert("点我干什么3??")
|
||
// } )
|
||
|
||
|
||
|
||
// 同步
|
||
//
|
||
// 异步 数据请求
|
||
// setTimeOut 延时 ? 定时
|
||
// 如何拿到异步的返回值 回调函数
|
||
// function a(money, callback) {
|
||
// var c = 0;
|
||
// setTimeout(function () {
|
||
// c = money * 10;
|
||
// callback(c)
|
||
// }, 3000)
|
||
// // return c
|
||
// }
|
||
|
||
|
||
// a(10, function(hb) {
|
||
// console.log(hb);
|
||
// })
|
||
|
||
|
||
</script>
|
||
|
||
</html> |