I have several div elements that act as buttons, each with a different background image set in the CSS file:
#button1 { background-image: url('../images/abc.png) }
#button2 { background-image: url('../images/def.png) }
#button3 { background-image: url('../images/ghi.png) }
Every button belongs to the class "button".
Additionally, there is a div with the class "popup". When any button is clicked, the class "isActive" is added.
My goal is to extract the background image of the button with the "isActive" class and apply it to the "popup" div.
I attempted to achieve this using jQuery:
var bg;
bg = $('.isActive').css('background-image')
console.log(bg)
$('.popup').css('background-image', bg )
However, the console.log returns the full path, such as:
file:///C:/Users/me/projects/images/abc.png
Is there a more elegant way to retrieve only the relative path without including "file://" and so on, just "../images/abc.png" as specified in the CSS?