Q:

Animate the hiding and showing of two divs, delaying the first before showing it using jquery

0

Animate the hiding and showing of two divs, delaying the first before showing it. using jquery

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

HTML Code :

<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-git.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Animate the hiding and showing of two divs, delaying the first before showing it.</title>
</head>
<body>
<p><button>Run</button></p>
<div class="div1"></div>
<div class="div2"></div>
</body>
</html>

CSS Code :

 div {
 position: absolute;
 width: 50px;
 height: 50px;
 float: left;
 }
 .div1 {
 background-color: red;
 left: 0;
 }
 .div2 {
 background-color: green;
 left: 80px;
 }
 

JavaScript Code :

$( "button" ).click(function() {
$( "div.div1" ).slideUp( 300 ).delay( 800 ).fadeIn( 400 );
$( "div.div2" ).slideUp( 400 ).fadeIn( 300 );
});

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now