This question has already been answered:

I write the code of such a plan but it does not work.

$(".mapopen").click(function() { $(".top_rightmenu ul li a:after").hide(); }); 

Reported as a duplicate by the participants soledar10 , sercxjo , tutankhamun , Duck Learning to Hide , Streletz 7 Sep '16 at 20:35 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

1 answer 1

:after is a pseudo-element, you will not be able to influence it directly from the code, only through the parent element

 $(".mapopen").click(function() { $(".top_rightmenu ul li a").addClass('hide-after); }); 

And in the css list

 .top_rightmenu ul li a.hide-after:after {display:none}` 

To return :after just remove the class from the link

  • And how to make an action analogous to .toggle ()? So that when you click on a link, the class is added / deleted? - Alexander
  • To do this, use .toggleClass('hide-after); instead of .addClass('hide-after); - Vitaliy Emelyantsev