SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Animation(elem){
  2. // code tests the application of js arrow function
  3. // date August 18, 2018
  4. this.elemid = document.querySelector('#'+elem)
  5. }
  6. Animation.prototype = {
  7. constructor: Animation,
  8. color: ['red', 'blue', 'black', 'yellow'],
  9. display:function(){
  10. var len = this.color.length;
  11. var index = 0;
  12. setInterval(()=>{
  13. if(index < len){this.elemid.style.backgroundColor = this.color[index];
  14. index++;
  15. }else{
  16. index =0;
  17. this.elemid.style.backgroundColor = this.color[index]
  18. }
  19.                
  20. },3000);
  21. }
  22. };
  23.     var testDiv = new Animation('test');// create instance of the class
  24.     testDiv.display();
  25.     var test2 = new Animation('test2');// create another instance
  26.     test2.display()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top