this. $. id only returns Undefined

Asked

Viewed 89 times

1

I’m using Polymer 2.x, I’m trying to do a pre-load for the page, I made a div with a load gif and I’ll take it with setTimeout... But in the script when I use this. $. load it returns Undefined. Could someone help me put None display in div?

Follows the code

ready(){
   super.ready();
   setTimeout(function(){
     this.$.load.classList.add('hidden'); //Classe adiciona display none
   }, 4000);
}

<div id="load">
   <img src="/* GIF */" alt="Loading..."/>
</div>

1 answer

1


I managed to solve, created a variable to save this, and used it to add the class. Below

ready(){
    super.ready();
    var element = this
    setTimeout(function(){
      element.$.load.classList.add('hidden');
    }, 4000);
  }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.