+ 3

Âżi can change the style of any element / as ?

ÂżHow do change styles within in a script?

26th Jun 2017, 11:19 PM
Christian Navarro
Christian Navarro - avatar
2 Answers
+ 1
Javascript offers the possibility, thanks to being an interactive language, to allow to make any type of modification in the original style of a page and in addition without that it is necessary at all to reload the page of the server. The syntax is as follows: document.body.style.fontSize="24px" document.getElementById("id").style.property="value" The first method allows the style to be applied generally to the document and the second is more specific, when addressed to a block or element defined by an ID identifier.
30th Jun 2017, 1:09 AM
Teresa Rodriguez
Teresa Rodriguez - avatar
0
This an example taken from the JS Sololearn Course (DOM&Event, changing element style) /*Take a look to the entire course , but to provide an answer to your post, see this*/ <div id="demo" style="width:200px">some text</div> <script> var x = document.getElementById("demo"); x.style.color = "6600FF"; x.style.width = "100px"; </script> Every html element's style can be modified by a javascript...
26th Jun 2017, 11:45 PM
BenjiSolo
BenjiSolo - avatar