Using JavaScript to change in-line styles

Open jsobject.html and save it as jsinline.html.  Delete the four lines of code in the function.

Anything which can be set using CSS can be changed by JavaScript. Paste this line of code into where the four lines of code were.

window.document.body.style.fontFamily="Script";

Save and load the page (remember to open the console to see errors).  When you click on the red word the font should change.  If not and if there are no errors then try any distinctive font which exists on your system.  Change Script for Symbol, Wingdings, Math or something else.

Try each of these in turn by pasting them into your function. Replace what is already there, save, refresh and then click on the red word. If the changed script doesn't seem to work it may be your browser using the old script (caching it). Press CTRL-F5 on your keyboard to bypass the cache (or use a different browser which has not loaded the page before).

window.document.body.style.fontSize="30px";
window.document.body.style.fontStyle="italic";
window.document.body.style.padding="100px";

On the whole any style can be changed just by replacing the hyphen in the CSS property with the capitalised first letter convention (e.g. font-size becomes fontSize as above).