我正在努力使用纯粹的JS下载。 我的代码是这样的:
<html>
<head>
<meta charset="utf-8"/>
<style>
.smallImg{
width: 100px;
height: 100px;
border: 1px solid black;
}
#target{
visibility: hidden;
}
</style>
</head>
<body>
<div id="src">
<img class="smallImg" src="https://www.google.co.in/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"/>
<div id="target">
<img class="smallImg" src="https://www.google.co.in/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png">Target</img>
</div>
</div>
<div>
<p>Hi this is used to get away focus</p>
</div>
<script>
(function(){
var src= document.getElementById('src');
var target =document.getElementById('target');
src.addEventListener('click',function(){target.style.visibility='visible';},false);
target.addEventListener('blur',function(){target.style.visibility='hidden';},false);
})();
</script>
</body>
</html>
单击src div时,我的目标设置为可见,但是当我通过单击&#34松开焦点时,嗨这是....&#34;文字,我的目标div没有隐藏。
控制台也没有错误。 我做错了什么,我怎么能正确地做到这一点?