how to remove css property using javascript?

前端 未结 10 1735
醉话见心
醉话见心 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:04

    To change all classes for an element:

    document.getElementById("ElementID").className = "CssClass";
    

    To add an additional class to an element:

    document.getElementById("ElementID").className += " CssClass";
    

    To check if a class is already applied to an element:

    if ( document.getElementById("ElementID").className.match(/(?:^|\s)CssClass(?!\S)/) )
    

提交回复
热议问题