Sanskar Tiwari
IndianAppGuy Blog

IndianAppGuy Blog

JS learning of the day

Sanskar Tiwari's photo
Sanskar Tiwari
·Jul 13, 2022·

1 min read

Subscribe to my newsletter and never miss my upcoming articles

So today i am working on click2contact.app its a chat widget, So i have added option in the website to update the widget and get the code

Problem: I need to set styling on selection from drop down

here is how i did it first, DID NOT WORKED

   document.getElementById("divContainer").style.position = "fixed";
      document.getElementById("openButton").style.position = "fixed";

this DID WORKED

     var style = document.createElement("style");
      style.innerHTML = `#divContainer{
        position: fixed;
      } #openButton{
        position: fixed;
      }`
      document.head.appendChild(style);

I am wondering why first did not worked anyone faced something similar?

 
Share this