How to animate :before selector with jQuery

2020-04-15 21:10发布

问题:

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:

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

When you do this, it will work:

pilot_shadow = $('#remote_control:before');