I have an object that goes
'buttonProperties' {
backgroundColor : 'green'
fontSize : '10px'
}
How would I make the button use those properties using a method like:
Object.keys(buttonProperties).forEach((x) => {
button.style[x] = buttonProperties[x];
})
const buttonProperties = {
backgroundcolor: 'green',
textSize : '10px'
},
button = document.getElementById('button')
button.addEventListener('click', () => {
Object.keys(buttonProperties).forEach((x,i) => {
button.style[x] = buttonProperties[x]
})
})
<button id = 'button'>Submit</button>