Why isn't my JavaScript code working inside my webpage?

Hi!
I have a simple html, css and JavaScript code that is working outside shopify but not inside shopify.

I don’t know why


 
  

The code is working well in many places but not on shopify (changing a class value using JavaScript ''Backgroundcolor)
I have tried it using PageFly and Shopify normal page and template. (the code is not working)

Working on w3schoolsite, offline, and codepen

https://codepen.io/saliem-antoun/pen/ExopOEe

another dom javascript on ine the same page is working well, but not this one I added up

this dom is working

document.getElementById('retailer').className = 'achimages-unlocked';

this one is not (in shopify)

document.getElementById("progressvalue").style.backgroundColor = "purple";

Any ideas???am I missing anything?

Solved
It is crazy but the script tag need to be inside the div (don’t know why)