适用场景:消息提示、提示后页面跳转等
html代码:
<p class="msg"></p>
<style>
.msg{
font-size: 14px;
background: #F7DA55;
padding: 9px;
color: #676767;
display: none;
}
</style>
jquery代码:记得头部引入Jquery哦
// 延迟3秒隐藏元素
$('.msg').show();
$('.msg').html('用户名和密码不能为空!');
$('.msg').delay(3000).hide(300);
// 延迟3秒页面跳转
setTimeout(function(){
window.location.href = '/'
},3000);
// 以上代码组合使用可达到3秒后页面跳转