使用javascript编辑.css(带括号)

使用javascript编辑.css(带括号),javascript,css,Javascript,Css,我看到一些线程在讨论这个问题,但我看不到任何人在.css中有括号时如何更改.css 我的标题中有一个.css,我想让我的用户能够更改背景颜色和文本颜色 在我的网站中使用inspector,我检测到了哪些CSS可以做到这一点 颜色文本在此.filepond文件中: .filepond--file { position: static; display: -ms-flexbox; display: flex; height: 100%; -ms-flex-align: start

我看到一些线程在讨论这个问题,但我看不到任何人在.css中有括号时如何更改.css

我的标题中有一个.css,我想让我的用户能够更改背景颜色和文本颜色

在我的网站中使用inspector,我检测到了哪些CSS可以做到这一点

颜色文本在此.filepond文件中:

.filepond--file {
  position: static;
  display: -ms-flexbox;
  display: flex;
  height: 100%;
  -ms-flex-align: start;
  align-items: flex-start;
  padding: 0.5625em 0.5625em;
  color: #fff;
  border-radius: 0.5em;
}
背景如下:

[data-filepond-item-state='processing-complete'] .filepond--item-panel {
  background-color: #369763;
}
我应该如何使用javascript更改这两个东西的颜色?
谢谢

您不需要编辑css样式表。 您可以将自己的样式元素添加到页面中,这样可以覆盖以前的样式

e、 g

例如,如果您将下面的代码复制粘贴到StackOverflow开发人员控制台,它将使post代码变为黑白

var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = '.prettyprint { color: white; background: black }';
document.getElementsByTagName('head')[0].appendChild(style);

如何看待这个函数:Hello可能是重复的,即使样式中有括号,它也可以工作?第一个被接受的答案很可能是这样的。该函数的第二个答案只是将样式附加到选择器。我认为该函数非常适合您的用例。指定选择器,指定背景色,win!您应该在发布之前对此进行测试。还有,document.head。
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = '.prettyprint { color: white; background: black }';
document.getElementsByTagName('head')[0].appendChild(style);