how to remove css property using javascript?

前端 未结 10 1736
醉话见心
醉话见心 2020-11-27 12:46

is it possible to remove a CSS property of an element using JavaScript ? e.g. I have div.style.zoom = 1.2, now i want to remove the zoom property through JavaS

10条回答
  •  抹茶落季
    2020-11-27 13:02

    You have two options:

    OPTION 1:

    You can use removeProperty method. It will remove a style from an element.

    el.style.removeProperty('zoom');
    

    OPTION 2:

    You can set it to the default value:

    el.style.zoom = "";
    

    The effective zoom will now be whatever follows from the definitions set in the stylesheets (through link and style tags). So this syntax will only modify the local style of this element.

提交回复
热议问题