为什么监听事件点击了没有反应

浪奔的小三爷 2020-12-19 02:58:10
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
padding: 0;
margin: 0;
}
.login{
text-align: center;
font-size: 24px;
}
a{
text-decoration: none;
color: #000000;
}
.login_frame{
display: block;
width: 512px;
height: 280px;
background-color: rgb(255,255,255);
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
box-shadow: 0px 0px 20px 0px #ddd
}
.login_title{
position: relative;
width: 100%;
font-size: 18px;
text-align: center;
margin: 20px 0;
}
body{
background-color: rgb(178, 178, 178);
}
input{
height:35px;
width:370px;
outline: none;
border: 1px solid rgb(0,0,0,.2);
}
label{
float: left;
width: 90px;
text-align: right;
margin-right: 10px;
line-height: 39px;
height:39px;
}
.login_input{
margin-bottom: 25px;
}
.login_btn{
width: 260px;
height: 45px;
border: 1px solid rgb(0,0,0,.2);
position: fixed;
bottom: 30px;
left: 130px;
text-align: center;
line-height: 45px;
}
span{
position:absolute;
top: -40px;
right: -20px;
/* border: 1px solid; */
width: 42px;
height: 42px;
border-radius: 50% 50%;
text-align: center;
line-height: 42px;
background-color: rgb(255,255,255);
font-size: 15px;
}
</style>
</head>
<body>
<div class="login"><a href="javascript:;" id="link">点击,弹出登录框</a></div>
<div class="login_frame">
<div class="login_title">登录会员<span><a href="" id="closebtn">关闭</a></span></div>
<div class="login_input">
<label>用户名:</label><input type="text" placeholder="请输入用户名">
</div>
<div class="login_input">
<label>登录密码:</label><input type="text" placeholder="请输入密码">
</div>
<a href="javascript:;"><div class="login_btn">登录会员</div></a>
</div>
<script>
var link=document.querySelector('#link');
var login_frame=document.querySelector('.login_frame');
var closeBtn=document.querySelector('#closebtn');
link.addEventListener('clcik',function(){
login_frame.style.display='block';
})
closeBtn.addEventListener('click',function(){
login_frame.style.display='none';
})
</script>
</body>
</html>
...全文
399 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
shuxhan 2020-12-19
  • 打赏
  • 举报
回复
你第四行js click写成 clcik了,下次记得用编辑器写,不要拿txt,容易写错单词

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧