How to get a DOM element's ::before content with JavaScript?

后端 未结 2 847
旧时难觅i
旧时难觅i 2021-02-04 03:12

I want to know whether it is possible to get a DOM element\'s ::before content, which was set by CSS3.

I have tried some ways, but I still can\'t make it, s

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-04 04:00

    getComputedStyle() & getPropertyValue()

    image

    getComputedStyle(document.querySelector('span.search-box'), '::after').getPropertyValue('content');

    image

提交回复
热议问题