.innerHTML stores whatever is between the
start and end tags of the element as a string. Remember, if
there are other elements nested within this one, the
.innerHTML will contain tags.
.style.color stores the color of the text.
Remember, colors are specified as RGB triples in hex, so
"#ff0000" is red, for instance.
.style.background stores the background
color.
.style.fontFamily stores the font "family".
You can specify a particular font, or generic fonts like:
serif, sans-serif, monospace, cursive or fantasy.
.style.fontSize stores the size of the font.
There are several possibilities for units including pt
(points), px (pixels) and em (multiple of current font-size,
so 1em is the current font-size, 2em is twice the current
font-size, etc).
(look here) ← These parens are defined by
this code: (<b id="tryme">look here</b>)Enter some expressions into the interpreter to the right that manipulate the b/id=tryme element. Here are some good ones to try: document.getElementById("tryme").innerHTML = "Hello World!";
document.getElementById("tryme").style.color="#ff0000";
document.getElementById("tryme").style.background="#ffff00";
document.getElementById("tryme").style.fontFamily = "cursive";
document.getElementById("tryme").style.fontSize = "2.0em";
document.getElementById("tryme").innerHTML = 'this is a <a href="http://google.com">link</a>';
|
|
| This box has id="box1" | This box has id="box2" |
Use the interpreter below to:
|
| This box has id="box3" | This box has id="box4" |