如何使用javascript删除css属性? [英] how to remove css property using javascript?

查看:115
本文介绍了如何使用javascript删除css属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用JavaScript删除元素的CSS属性?
例如我有 div.style.zoom = 1.2
现在我想通过JavaScript删除缩放属性?

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 JavaScript ?

推荐答案

通常你无法从内置对象中删除属性,当然不能在IE中(style对象的zoom属性是IE扩展)

Typically You cannot remove properties from built-in objects like that, and certainly not in IE (the zoom attribute of the style object is a IE extension)

您可以将其设置为默认值:

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.

这篇关于如何使用javascript删除css属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆