简体   繁体   English

正则表达式模式以更改所有出现的颜色

[英]Regex pattern to change the color in all occurences

"<p><span style="color: rgb(255, 255, 255);">Beautifully hand designed brochure with arresting imagery created by the designers</span><em style="color: rgb(255, 255, 255);"> eminem.</em></p>"
"<p><span style="color: rgb(105,105,105);">Beautifully hand designed brochure with arresting imagery created by the designers</span><em style="color: rgb(255, 255, 255);"> eminem.</em></p>"

I want to change the rgb color (128,128,128) by making a script.我想通过制作脚本来更改 rgb 颜色(128,128,128)。 please help me to solve this请帮我解决这个问题

You can use this javascript code to change all span to the preferred rgb color:您可以使用此 javascript 代码将所有跨度更改为首选 rgb 颜色:

 document.querySelectorAll('span').forEach(element => { element.style.color = 'rgb(128,128,128)'; });
 <p><span style="color: rgb(255, 255, 255);">Beautifully hand designed brochure with arresting imagery created by the designers</span><em style="color: rgb(255, 255, 255);"> eminem.</em></p> <p><span style="color: rgb(105,105,105);">Beautifully hand designed brochure with arresting imagery created by the designers</span><em style="color: rgb(255, 255, 255);"> eminem.</em></p>

You can also change 'span' to whatever element you want to select and change.您还可以将“跨度”更改为您想要 select 并更改的任何元素。

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

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