Removing CSS Property Using JavaScript
Is it possible to remove a CSS property of an element using JavaScript? For instance, if you have a CSS property div.style.zoom set to 1.2, how do you remove the zoom property through JavaScript?
There are two options:
Option 1: Using removeProperty Method
The removeAttribute method allows you to remove a style from an element. You can use it as follows:
<code class="javascript">el.style.removeProperty('zoom');</code>
Option 2: Setting Default Value
You can also set the property to its default value:
<code class="javascript">el.style.zoom = "";</code>
This approach will set the zoom level to the default defined in your stylesheets. It only affects the local style of the specific element.
The above is the detailed content of How to Remove a CSS Property from an Element Using JavaScript?. For more information, please follow other related articles on the PHP Chinese website!