1 回答
TA贡献1803条经验 获得超3个赞
为什么不使用 JQuery 而不使用 PHP 回显代码。并检测元素是否可见以触发隐藏功能。或者只是使用警报框的关闭按钮。
setTimeout(function() {
if ($("#noOperator").is(":visible")) {
//$('#noOperator').hide();
$("#noOperator").animate({
'margin-top' : "-50%",
'opacity' : '0',
'visibility' : 'hide'
},1000);
console.log("hiding now")
}
}, 1000); // hide the element if visible after 1 second
//or just use the button on the alert box
//if you want it just uncomment below
//$('.close').click(function(){
// $('#noOperator').hide();
//});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<div class="alert alert-warning alert-dismissible" id="noOperator" role="alert">
<strong>Not certified! </strong>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span></button>
</div>
如果您将其更改为:
echo '<script>
setTimeout(function() {
$("#noOperator").fadeTo(2000, 500).slideUp(500, function(){
$("#noOperator").slideUp(500);
});
}, 3000);
</script>';
- 1 回答
- 0 关注
- 195 浏览
添加回答
举报