gpt4 book ai didi

jquery - jQuery 无法识别 CSS 伪代码

转载 作者:技术小花猫 更新时间:2023-10-29 10:55:33 25 4
gpt4 key购买 nike

jQuery 无法识别我的 CSS 伪代码:这是我的代码

CSS:

h1 {
background: red;
width: 100px;
display: inline-block;
}

h1:after {
content:" | ";
background:blue;
display: inline-block;
}

然后在 jQuery 中我这样做:

console.log($('h1').css('backgroundColor'));

是节目:

rgb(255, 0, 0)

但是当我这样做的时候:

console.log($('h1:after').css('backgroundColor'));

是节目:

未定义

最佳答案

您不能选择 css 伪元素,因为它们实际上并不存在于 DOM 中

关于jquery - jQuery 无法识别 CSS 伪代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9280986/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com