<!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>click函数的使用</title>
</head>
<body>
<button onclick="dj()" id="anniu">你好世界</button>
<button id="haha" onclick="haha()">haha</button>
<!-- 从这里看出可以是windows触发的 -->
<input type="file" onchange="loadImageFile()" id="upload" />
<script>
function dj() {
// console.log("nihaoshijie");
// document.getElementById("haha").click();
// 可能这是一个动作所以输出的是未定义
// console.log(document.getElementById("haha").click());
filenamedz = document.getElementById("upload").click(); //也有可能是它触发的
filename = document.getElementById("upload");
console.log(filename);
}
function loadImageFile() {
console.log(this); //确实是windows,以后不知道是就输出一下
//这里的this应该是指向的是那个按钮,假如我这里写this指的是windows调用
var file = filename.files;
console.log(file);
}
function haha() {
console.log("lj");
}
</script>
</body>
</html>
还没有评论,来说两句吧...