简体   繁体   English

Javascript:选择具有特定字体大小或字体粗细的所有元素

[英]Javascript: selecting all elements that have a specific font-size or font-weight

in JavaScript, is there a way to select all elements that have a specific style, like a font size or font weight or color without using class or ID?在 JavaScript 中,有没有办法在不使用 class 或 ID 的情况下将所有具有特定样式(如字体大小、字体粗细或颜色)的元素转换为 select?

You could select all elements ( querySelector("*") ) then loop over the results testing the computedStyle .您可以 select所有元素 ( querySelector("*") ) 然后循环测试computedStyle的结果。

Far from efficient, but the only way I can think of.远非高效,但我能想到的唯一方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM