我知道我可以使用window.getComputedStyle(el)来获取浏览器DOM中元素的计算样式。
但是,是否存在与名称document.resolveAllClassRulesToInlineStyles()更接近的东西,从而允许我执行JavaScript memory中文档的名称所暗示的操作。
输入:
.warning {
color: red;
}<html>
<div style="color: blue;">Blue</div>
<div class="warning">Red</div>
</html>
输出:
<html>
<div style="color: blue;">Blue</div>
<div style="color: red;">Red</div>
</html>
发布于 2020-03-25 11:52:42
我认为JS很难为html做内联风格。
但是你可以尝试这些在线工具来做同样的事情。
<!-- Test Example -->
<html>
<div style="color: blue;">Blue</div>
<div class="warning">Red</div>
</html>
<style>
.warning {
color: red;
}
</style>
<!-- Output -->
<html>
<div style="color: blue;">Blue</div>
<div class="warning" style="color: red;">Red</div>
</html>
<style>
.warning {
color: red;
}
</style>发布于 2020-03-26 05:15:08
https://stackoverflow.com/questions/60838033
复制相似问题