Reputation:
Is there a way to use AddClass in jQuery to add a class while a page and the assets are loading?
For example you could add a class of loading to the body tag.
You can't use the DOM ready function can you?
Upvotes: 1
Views: 537
Reputation: 22183
This may give you some ideas of how to go about doing this.
https://plus.google.com/116910304844117268718/posts/UkaymyuTzaF
What I usually do is setup a attribute and then have JS turn it off when all the assets are ready. In CSS then I define a loading animation on areas of the body where I want them to appear.
Upvotes: 0
Reputation: 2189
Putting my comment as an answer so this question can be marked as answered...
Set the loading class in the html and then use .removeClass
to remove it once the document has finished loading.
Upvotes: 3