karamata/js/script.js

44 lines
911 B
JavaScript

const name = document.querySelector(".name");
// I commented the following line out by putting '//' at the start of the line.
//console.log(document);
// red, green, blue, yellow, black, white, or #ccc or #5ef21d
function changeColor(color) {
name.style.color = color;
}
function changeWeight() {
let weight;
if (name.style.fontWeight == 'bold') {
weight = 'normal';
} else {
weight = 'bold';
}
name.style.fontWeight = weight;
}
// normal or small-caps
function changeVariant() {
let variant;
if (name.style.fontVariant == 'small-caps') {
variant = 'normal';
} else {
variant = 'small-caps';
}
name.style.fontVariant = variant;
}
// normal, italic, or oblique
function changeStyle() {
let style;
if (name.style.fontStyle == 'italic') {
style = 'normal';
} else {
style = 'italic';
}
console.log('style = ', style);
name.style.fontStyle = style;
}