I am trying to get a value from Javascript into my HTML code for a value in padding. I have a javascript function that defines the variable i.
function myFunction() {
var i = 90;
}
I want to use that variable for padding in a div element like this.
The variable i from Javascript
↓
<div padding=" ">text</div>
But I don't know how to get that from Javascript into HTML (I'm sort of new to it and coding).
I have tried looking up on how to get Javascript values into HTML, but nothing has helped. Can you help?
paddingattributes like that that control their visible padding styles. You have to set theirstyleattributes using something called the CSSOM. See for example changing top padding in javascript