0

I am trying to get the contents of a class that is inside my attached stylesheet

filename: style.css

.my-class{
  background-image: url("img/build_animation_menu_no_loop_2.png");
  background-repeat: no-repeat;
  pointer-events: none;
  background-size: contain;
}

it is attached to the following div:

<div id="myclass" class="my-class">some text</div>

I would like to extract the url from the background-image to a JS variable, as such

let url = "img/build_animation_menu_no_loop_2.png"

How can I do that in pure javascript (no Jquery)?

Ewald Bos
  • 1,312
  • 1
  • 16
  • 28
  • That's a ruleset, not a class. CSS doesn't have classes (although it has class selectors). HTML has classes. (JS also has classes but they are unrelated). – Quentin May 13 '22 at 13:09

0 Answers0