删除元素上的样式 [英] Remove Style on Element
本文介绍了删除元素上的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道这是否可能。
有这个元素
<div id="sample_id" style="width:100px; height:100px; color:red;">
因此,我要移除 width:100px; :100px;
So I want to remove width:100px; and height:100px;
结果将是
<div id="sample_id" style="color:red;">
任何帮助都会受到影响。 :)
Any help would be apprreciated. :)
推荐答案
您可以使用纯JavaScript编辑样式。无需库,所有浏览器都完全支持。
You can edit style with pure Javascript. No library needed, totally supported by all browsers.
var element = document.getElementById('sample_id');
element.style.width = null;
element.style.height = null;
有关详细信息,请参阅 HTMLElement.style 关于MDN的文档。
For more information, you can refer to HTMLElement.style documentation on MDN.
这篇关于删除元素上的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文