问答详情
源自:4-1 遮罩全屏及自动居中浮层

为什么没有关闭效果啊

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>无标题文档</title>

<style type="text/css">  


div{

 width:400px; height:400px;

 position: relative; border:solid 1px red;}

.close{ position: absolute; right:0; top:0;}

img{ width:400px; height:400px;}


</style>

<script>

function hide(){

var get=document.getElementById("kk").style.display='none'



}



</script>

</head>


<body>

<div class="kk"><a href="#"><img src="http://a2.qpic.cn/psb?/V13ve7901udi4I/TGaUcEPsZFinuujGs5TJCXIWyhijQpwES5iwiU1frAQ!/b/dG8BAAAAAAAA&bo=RgKmAgAAAAADB8I!&rf=viewer_4"/></a><a href="javascript:hide()" class="close">关闭</a></div>

</body>

</html>


提问者:慕丝8848655 2016-06-19 19:32

个回答

  • 亹v亹
    2016-06-20 20:01:06

    div中kk设定的是class值,js中获取kk是id值,所以找不到元素。