added functionality and some DOM manipulation
This commit is contained in:
parent
952ca111bb
commit
b46b2dc3e7
3 changed files with 55 additions and 7 deletions
42
js/script.js
42
js/script.js
|
@ -1,5 +1,43 @@
|
|||
|
||||
const name = document.querySelector(".name");
|
||||
|
||||
function changeColor() {
|
||||
name.style.color = "blue";
|
||||
// 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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue