Keaire
Keaire

Reputation: 899

Reset style properties

I'm setting properties of the :root pseudo class in this manner:

$(":root")[0].style.setProperty(variable, value);

If I wanted to reset all the properties precedently set, how can I do? Without specifying every variable set, assigning empty values.

Upvotes: 0

Views: 122

Answers (2)

Keaire
Keaire

Reputation: 899

Found a way, just reset the style object:

$(':root')[0].style = {}

Upvotes: 0

Devansh J
Devansh J

Reputation: 4194

Umm.. how about you use all:unset. So:

$(":root")[0].style.setProperty("all", "unset");

Demo:

h1 {
   color: red;
   all: unset;
}
<h1>Hello this should not be red nor should have default h1 styles</h1>

Upvotes: 1

Related Questions