亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用php觸發元素隱藏

如何使用php觸發元素隱藏

PHP
慕的地8271018 2021-11-26 19:57:05
我有以下 php 代碼回顯警報。echo '<div class="alert alert-warning alert-dismissible" id = "noOperator" role="alert" >      <strong>Not certified! </strong>'.$checkBoxValue.' is not certified to use '.$needleType.'      <button type="button" class="close" data-dismiss="alert" aria-label="Close">      <span aria-hidden="true">&times;</span></button>      </div>';但是我想在它顯示后關閉這個警報。因此,我再次給出了以下作為回聲。echo ' <script>      $("#noOperator").fadeTo(2000, 500).slideUp(500, function(){           $("#noOperator").slideUp(500);      });       </script>';但它不起作用有誰知道為什么?
查看完整描述

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">&times;</span></button>

</div>

如果您將其更改為:


echo '<script>

         setTimeout(function() {

            $("#noOperator").fadeTo(2000, 500).slideUp(500, function(){

              $("#noOperator").slideUp(500);

            });

         }, 3000);

      </script>';


查看完整回答
反對 回復 2021-11-26
  • 1 回答
  • 0 關注
  • 208 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號