Web design: JavaScript: changing style of an element
The tutor returns to JavaScript to talk about changing element style.
With JavaScript, the appearance of an element on the page can be changed by actions offered to the visitor. For example, the button below can be clicked to change this paragraph.
The command to change an element’s text color to green from within a JavaScript function is
document.getElementById(“element_id”).style.color=”green”;
The command to increase an element’s font size by 75% is
document.getElementById(“element_id”).style.fontSize=”175%”;
I’ll be discussing more JavaScript style changes in coming posts:)
Source:
Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.