<!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>Document</title>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
</head>
<body>
<div>
</div>
<div id="vid" style="background: cadetblue;height: 350px;width: 520px;">
<button id="closeVid">关闭</button>
<video class="ni" id="vide" controls="controls" style="height: 350px;width: 520px; bottom: 0px;" src="http://192.168.0.106/GDBFILE/20200611094709/2019管6547成果/2.MP4"></video>
</div>
</body>
</html>
<script>
$("#closeVid").click(function() {
//$("#vid").style.display = "none";
var why = document.getElementById("vid");
why.style.display = "none";
});
</script>
隐藏div功能
直接用jquery选择div
//$("#vid").style.display = “none”;
报错:
Uncaught TypeError: Cannot set property ‘display’ of undefined
不知道为啥
var why = document.getElementById(“vid”);
why.style.display = “none”;
就可以。不解