0

(new edit) If you say duplicate of another question, can you give me a solution of my question, I cant solve my problem in that question

since my previous question had marked as duplicate question, but there is different, that post cannot solve my problem, so I re-post my question here. If you think you can solve my problem via the post, please write the answer here. Thanks!

In my .html

<header class="bg-image">
...

<style>
    .bg-image:before {
        ...
        background: #333 url("1.jpg") no-repeat top center;
    }
</style>

</header>

and now I want to change the "1.jpg" to "2.jpg" using jQuery but I cannot select ".bg-image:before" to change it

In case I must use the above style code in html to do an effect How can I change to "2.jpg" using jQuery?

Community
  • 1
  • 1
Hoko MaJi
  • 21
  • 3
  • 3
    No you cannot target :before, :after Read here: [link](http://stackoverflow.com/questions/17788990/access-the-css-after-selector-with-jquery) – Sagar Dec 06 '16 at 00:25
  • 3
    Possible duplicate of [Selecting and manipulating CSS pseudo-elements such as ::before and ::after using jQuery](http://stackoverflow.com/questions/5041494/selecting-and-manipulating-css-pseudo-elements-such-as-before-and-after-usin) – junkfoodjunkie Dec 06 '16 at 00:30
  • Read this [answer](http://stackoverflow.com/a/21709814/4305494). It does exactly what you are asking. – Ricky Ruiz Dec 06 '16 at 00:36
  • 1
    thank you @Ricky, I solved from the answer – Hoko MaJi Dec 06 '16 at 01:40

0 Answers0