Show hide by time

Description

The following code shows how to show a Div based Dialog in animation.

Example


<html>
<head>
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
  <!--from w w w .  j a  v  a 2s  .c  o  m-->
</script>

<script type='text/javascript'>
  $(document).ready(function() {
    $('input#tmpOpen').click(function($e) {
      $('div#myDialog').show(5000);
    });

    $('input#tmpClose').click(function($e) {
      $('div#myDialog').hide(5000);
    });
  });
</script>
<style type='text/css'>
div#myDialog {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 500px;
  height: 200px;
  margin: -101px 0 0 -251px;
  border: 1px solid rgb(128, 128, 128);
}

div#tmpButtons {
  position: absolute;
  bottom: 5px;
  right: 5px;
}
</style>
</head>
<body>
  <input type='submit' id='tmpOpen' value='Open' />
  <div id='myDialog'>
    <p>Dialog content</p>
    <div id='tmpButtons'>
      <input type='submit' id='tmpClose' value='Close' />
    </div>
  </div>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities