I am creating a js for an HTML file. I want to manipulate the css of the div.
One of the ways is to use this: -
div.style.left = "30px";
However, in my code user tells how the HTML is to be manipulated. I want to make it dynamic. I have set a variable with the property I want to change like this: -
let myProperty = "top", value = "30px";
Now, I want to use this as my CSS modifier in js like this: -
myDiv.style.myProperty = value;
I have tried setAttributes() which is not working. How can I do this?