質問

私はページをリロード時に一定期間後(Gmailで「メールが送信され成功した」のような)です。

私はdivを非表示にする必要があります

私はそれを行うことができますどのように?

役に立ちましたか?

解決

ここでは、あなたのテストに基づいて完全な作業例です。あなたは間違っている場所を把握するために、現在持っているものと比較します。

<html> 
  <head> 
    <title>Untitled Document</title> 
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript"> 
      $(document).ready( function() {
        $('#deletesuccess').delay(1000).fadeOut();
      });
    </script>
  </head> 
  <body> 
    <div id=deletesuccess > hiiiiiiiiiii </div> 
  </body> 
</html>

他のヒント

のjQueryの古いバージョンでは、あなたは「JavaScriptの道」を使用してのsetTimeout

setTimeout( function(){$('div').hide();} , 4000);

または

setTimeout( "$('div').hide();", 4000);

最近 jQueryを使ってこのソリューションの1.4が追加されています:

$("div").delay(4000).hide();

もちろん、有効な jqueryのセレクタを使用して正しい要素で「DIV」を交換し、 文書の準備ができにあるときに関数を呼び出します。

setTimeout('$("#someDivId").hide()',1500);

$().ready(function(){

  $('div.alert').delay(1500);
   $('div.alert').hide(1000);
});
div.alert{
color: green;
background-color: rgb(50,200,50, .5);
padding: 10px;
text-align: center;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="alert"><p>Inserted Successfully . . .</p></div>

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top