Fade an element away during animation in jQuery

Description

The following code shows how to fade an element away during animation.

Example


<!DOCTYPE html>
<html>
<head>
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
  $(function() {<!-- w  w  w.  ja  va 2 s.c  o  m-->
    var winWidth = $(document).width();
    var duration = 1000;
    $(document).click(function(event) {
      $("#alien").animate({
        opacity : 0,
      }, duration);
    });
  });
</script>
</head>
<body>
  <div id="alien">java2s.com</div>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities