Files
ClassContent/历届学生/刘合群/2019-07-19/enevt.html
2024-09-27 02:06:13 +08:00

46 lines
1.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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">
<title>事件</title>
</head>
<body>
<p class="ddddd" onclick="demos()"> 点我触发事件 </p>
<button class="btn1">我是按钮</button>
<button class="btn2">我是按钮2</button>
<script>
// 用户进行某项操作
// 浏览器有两"棵树"bom(window)dom(document)
// 通过js操作浏览器(刷新,打开窗口)bom
// 通过js操作页面上的html(显示隐藏元素,修改元素颜色)dom
function demos () {
alert("事件被触发")
document.querySelector(".ddddd").innerText = "哈哈哈哈"
document.title = "的回调古尔丹股权"
open("https://www.runoob.com/js/js-events.html")
}
document.querySelector(".btn1").onclick = function () {
alert(1)
}
// document.querySelector(".btn2").addEventListener("click", function() {
// alert(22222)
// })
</script>
</body>
</html>