How to animate :before selector with jQuery

2020-04-15 20:37发布

I have some element with :before pseudo selector define. I need to add some transition, animation for it but in CSS it's not possible. So i think that i can do this with jQuery but something is nor working right. Can you help me? This is my code:

var pilot = $('#remote_control'),
    pilot_shadow = $('#remote_control:before');
pilot.on({
    mouseenter: function(){
        pilot_shadow.animate({
            opacity: 0
        });
    }
});

1条回答
【Aperson】
2楼-- · 2020-04-15 21:20

If you use http://jquery.lukelutman.com/plugins/pseudo/jquery.pseudo.js

When you do this, it will work:

pilot_shadow = $('#remote_control:before');
查看更多
登录 后发表回答