Access the css ":after" selector with jQuery -


i have following css:

.pagemenu .active::after {     content: '';     margin-top: -6px;     display: inline-block;     width: 0px;     height: 0px;     border-top: 14px solid white;     border-left: 14px solid transparent;     border-bottom: 14px solid white;     position: absolute;     right: 0; } 

i'd change border-width of top, left, , bottom border using jquery. selector use access element? tried following doesn't seem working.

$('.pagemenu .active:after').css(         {             'border-top-width': '22px',             'border-left-width': '22px',             'border-right-width': '22px'         }     ) 

you can't manipulate :after, because it's not technically part of dom , therefore inaccessible javascript. can add new class new :after specified.

css:

.pagemenu .active.changed:after {  /* selector more specific, takes precedence on other :after */     border-top-width: 22px;     border-left-width: 22px;     border-right-width: 22px; } 

js:

$('.pagemenu .active').toggleclass('changed'); 

update: while it's impossible directly modify :after content, there ways read and/or override using javascript. see "manipulating css pseudo-elements using jquery (e.g. :before , :after)" comprehensive list of techniques.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -