有没有办法使用jQuery 选择/操作CSS伪元素,如::before和::after(以及带有一个分号的旧版本)?
例如,我的样式表具有以下规则:
.span::after{ content:'foo' }
Run Code Online (Sandbox Code Playgroud)
如何使用jQuery将'foo'更改为'bar'?
我background-color从 API 中得到一个变量名settings.brand_color。我想在 html 元素中使用该变量。我不能使用style属性,因为我:before在我的应用程序中使用了选择器。我想在我的 css 文件中传递该 API 变量并在我的:before伪选择器中使用它。
JSX
<input
id={languageLabel}
type="radio"
name="language-select"
value={languageLabel}
// defaultChecked={index === 0}
onChange={() => {
onLanguageChange(language, languageLabel);
}}
className="focus:ring-0 mr-5 my-18p default-style radio__input"
/>
<div className="radio__radio"></div>
Run Code Online (Sandbox Code Playgroud)
CSS
.radio__radio {
width: 24px;
height: 24px;
background-color: #d8d8d8;
border-radius: 50%;
box-sizing: border-box;
padding: 6px;
margin-right: 20px;
z-index: 1;
}
.radio__radio::after {
content: "";
width: 100%;
height: 100%;
display: block;
background: #f28b46;
border-radius: 50%;
transform: scale(0);
z-index: …Run Code Online (Sandbox Code Playgroud) 为什么这个代码段无法在按钮上运行?我该怎么做才能正确?
$('div.button:after').css({
display:'none'
})
Run Code Online (Sandbox Code Playgroud)