How to add :: before pseudo-element elements created dynamically using jQuery

I am creating some elements dynamically using jquery. (say with identifier test_element1 , test_element2 , etc.)

I have below CSS -

 div[id^=test_]:before { content: ""; height: 100%; width: 100%; box-shadow: #aaaaaa 0px 0px 10px inset; position: absolute; left: 0px; top: 0px; z-index: -1; } 

The ::before element is not displayed when checking an element. It appears only if test_element1 already present in my HTML (i.e. static content).

How to do ::before for my dynamic elements?

+6
source share
1 answer

the answer is that

You cannot manipulate pseudo-elements, for example: after and: before using javascript or jquery. You cannot even add dynamically.

-1
source

Source: https://habr.com/ru/post/977271/


All Articles