aaaa
This commit is contained in:
34
teaching/wanzhaoyi/shijian.html
Normal file
34
teaching/wanzhaoyi/shijian.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<!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>
|
||||
</head>
|
||||
<body>
|
||||
<!-- <div onclick="keyuo()"></div> -->
|
||||
<script>
|
||||
var shenti = document.getElementsByTagName("body")[0]
|
||||
// document.body => 选中body
|
||||
console.log(shenti);
|
||||
// document 首字母不大写
|
||||
var ele = document.createElement("div");
|
||||
// setattribute
|
||||
// 不要在html里面用关于样式的属性
|
||||
ele.setAttribute("style","width:100px;height:100px;background-color:red")
|
||||
ele.innerHTML="hello"
|
||||
console.log(ele)
|
||||
shenti.append(ele)
|
||||
|
||||
// ele.onclick=function(){
|
||||
// alert("world")
|
||||
// }
|
||||
|
||||
ele.addEventListener("click",function(){
|
||||
alert("world")
|
||||
})
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user