DOM Styling with JavaScript
By Querying an element or class, JS can style the content
var el = document.querySelector(name);
background color changed
this should not be displayed (place is freed)
this should be hidden (place is occupied)
the font color and size changed
var bgColor = document.querySelector('.bg');
bgColor.style.backgroundColor = 'pink';
var notDisp = document.querySelector('.dsp');
notDisp.style.display = 'none';
var hid = document.querySelector('.hid');
hid.style.visibility = 'hidden';
var fontCol = document.querySelector('.fnt');
fontCol.style.color = 'red';
fontCol.style.fontSize = '25px';
console.log(hid.style); //returns the style of an element
console.log(fontCol.style['color']);
//or
console.log(fontCol.style.color); //return a specific value (color)
back to main page