1 回答
TA貢獻1803條經驗 獲得超3個贊
為什么不使用 JQuery 而不使用 PHP 回顯代碼。并檢測元素是否可見以觸發隱藏功能?;蛘咧皇鞘褂镁瘓罂虻年P閉按鈕。
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 關注
- 208 瀏覽
添加回答
舉報
