例如,我有这样的jQuery的功能:
function example(){
var trigger = $('.image');
trigger.each(function(e){
// here I want to change the background color of the :after pseudo-element
$(this:after).css('background-color', 'red');
//^the above obviously doesn't work
});
}
我怎么可以添加,更改或删除CSS属性的$(this)
伪元素?
Jason,它不是重复的。重复只是要求改变伪元素的内容。我想改变CSS属性 –
改为切换一个类,并使用相关的CSS规则来处理伪元素,例如'$(this).addClass('red');'in CSS'.image.red:after {background-颜色:红色;}' –