aaaa
This commit is contained in:
48
teaching/lhj/kejian/js/domshijian.html
Normal file
48
teaching/lhj/kejian/js/domshijian.html
Normal file
@@ -0,0 +1,48 @@
|
||||
<!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>Document</title>
|
||||
<style>
|
||||
.btn{
|
||||
background:blue
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<button>点我弹窗</button>
|
||||
<script>
|
||||
// 绑定事件的方式
|
||||
// 1. 在html元素里面直接注册事件 <button onclick="tijiao()">提交</button>
|
||||
// 2. 从js script标签里面 先选中目标元素 然后通过选中元素.事件注册 来完成注册事件:
|
||||
// btn[0].ondblclick=function (){
|
||||
// alert("asd")
|
||||
// }
|
||||
|
||||
// 3. 从js script标签里面 先选中目标元素 然后通过选中元素.事件注册 在注册事件的时候直接使用 addeventlistener
|
||||
|
||||
window.onload=function(){
|
||||
console.log("我再加载")
|
||||
}
|
||||
var btn=document.getElementsByTagName("button")
|
||||
// btn[0].ondblclick=function (){
|
||||
// alert("asd")
|
||||
// }
|
||||
btn[0].addEventListener("click",tanchu)
|
||||
btn[0].style.width="200px"
|
||||
console.log(btn[0].style.width)
|
||||
|
||||
btn[0].className="btn"
|
||||
console.log(btn[0].style.background)
|
||||
|
||||
|
||||
function tanchu(){
|
||||
// alert("asd")
|
||||
console.log(event)
|
||||
}
|
||||
// keypress 长按 键盘事件
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user