add a method to remove style property
I think it's not bad to introduce removeProperty() method :)
This commit is contained in:
parent
291b5c05b9
commit
0ece900f50
1 changed files with 8 additions and 0 deletions
|
@ -128,6 +128,14 @@ setTimeout(() => document.body.style.display = "", 1000); // back to normal
|
|||
|
||||
If we set `style.display` to an empty string, then the browser applies CSS classes and its built-in styles normally, as if there were no such `style.display` property at all.
|
||||
|
||||
Also there is a special method for that, `elem.style.removeProperty('style property')`. So, We can remove a property like this:
|
||||
|
||||
```js run
|
||||
document.body.style.background = 'red'; //set background to red
|
||||
|
||||
setTimeout(() => document.body.style.removeProperty('background')); // remove background after 1 second
|
||||
```
|
||||
|
||||
````smart header="Full rewrite with `style.cssText`"
|
||||
Normally, we use `style.*` to assign individual style properties. We can't set the full style like `div.style="color: red; width: 100px"`, because `div.style` is an object, and it's read-only.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue