0

How to select .class::after in jQuery?

css looks like this:

.nume
{
    color: #463E3F;
    position: absolute;

}
.nume::after{
    background-color: #463E3F; 
    bottom: 0;
    content: '';
    display: block;
    height: 1px;
    opacity: 0;
}

and js looks like this:

$("body").click(function(){
    $(".nume").animate({top: "5%"});
  }); 
$("body").click(function(){
    $(".nume::after").animate({opacity: "1"});
  });

but $(".nume::after").animate({opacity: "1"}); is not working

Selecting and manipulating CSS pseudo-elements such as ::before and ::after using javascript (or jQuery) its now working either

  • 6
    Does this answer your question? [Selecting and manipulating CSS pseudo-elements such as ::before and ::after using javascript (or jQuery)](https://stackoverflow.com/questions/5041494/selecting-and-manipulating-css-pseudo-elements-such-as-before-and-after-usin) – ATP Nov 30 '20 at 19:10
  • Nope that does not work – Briciu Luiza Nov 30 '20 at 19:13
  • impossible https://stackoverflow.com/questions/17788990/access-the-css-after-selector-with-jquery – ATP Nov 30 '20 at 19:16
  • @BriciuLuiza I have personally tried some of the approaches suggested [in this answer](https://stackoverflow.com/questions/5041494/selecting-and-manipulating-css-pseudo-elements-such-as-before-and-after-usin) and they work. Pseudo elements, like before and after, are not part of the DOM, so it is not possible to select them directly like you are trying to do. – Edy Espinal Nov 30 '20 at 21:26

0 Answers0