console
setTimeout(function () {
var btn = document.getElementById('btn');
console.log('btn', btn);
console.log('input', document.querySelector('textarea'));
btn.addEventListener('tap', function () {
console.log('tap');
var popup = document.getElementById('popup');
popup.setAttribute('class', 'display-none');
})
}, 500)
<div>
<div class="tip">
<h2>zepto 穿透示例</h2>
<h4>请在移动设备上查看</h2>
</div>
<textarea placeholder="这是一个输入框"></textarea>
<div class="popup" id="popup">
<span>这是一个弹出窗口哦 ~_~</span>
<div id="btn">关闭弹出窗口</div>
</div>
</div>
.tip {
position: absolute;
top: 0;
left: 0;
text-align: center;
width: 100%;
}
textarea {
width: 65%;
height: 100px;
margin-left: 17.5%;
margin-top: 200px;
border: 1px solid green;
border-radius: 4px;
}
.popup {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: rgba(0,0,0,.5);
text-align: center;
}
.popup span{
display: block;
margin-top: 150px;
color: white;
}
.popup div {
width: 130px;
height: 50px;
line-height: 50px;
border-radius: 8px;
outline: none;
border: 0px;
background-color: white;
margin: auto;
margin-top: 50px;
}
.display-none {
display: none;
}