Using jQuery change the color of any div that is animated

  • جي كويري

Using jQuery change the color of any div that is animated.

الأجوبة

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>Change the color of any div that is animated.</title>
</head>
<body>
<div id="div1"></div>
<div id="div2"></div>
<div id="div3"></div>
<button id="button1">Click to see the effect</button>
</body>
</html>

CSS Code:

button {
    display: block;
    margin: 20px 0 0 0;
    }   

div {
    background: #B0E0E6;
    border: 1px solid #e30ae8;
    width: 20px;
    height: 30px;
    margin: 0 5px;
    float: left;
  }
  div.colored {
    background: #000000;
  }

JavaScript Code :

$( "#button1" ).click(function() {
  $( "div:animated" ).toggleClass( "colored" );
});
 
function animateIt() {
  $( "#div1,#div2" ).slideToggle( "slow", animateIt );
}
 
animateIt();
هل كان المحتوى مفيد؟

معلومات ذات صلة

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...