ajax請(qǐng)求接口之后,要提示這次請(qǐng)求是否成功,我們都會(huì)彈出一個(gè)小提示框,自己手寫了一個(gè),記一下
css部分
//css 部分
.mark-box-text {
width: 80%;
height: auto;
position: fixed;
left: 50%;
top: 20%;
transform: translateX(-50%);
z-index: 5;
background-color: rgba(0,0,0,.6);
color: #fff;
text-align: center;
line-height: 2rem;
font-size: .8rem;
border-radius: .25rem;
}
js部分
function markBox(str) {
if(timer != null) {
return
}
$('.main-container').append('<div class="mark-box-text">'+str+'</div>')
timer = setTimeout(function() {
$('.mark-box-text').remove()
timer = null
}, 2000)
}