var elem = document.querySelector('#some-element');
// Set color to purple
elem.style.color = 'purple';
// Set the background color to a light gray
elem.style.backgroundColor = '#e5e5e5';
// Set the height to 150px
elem.style.height = '150px';
how to get the value of a style of an element in javascript
to get a property value of an element in js :
html:
<div class="element" style="color: red;">Red hot chili pepper!</div>
js:
const your_element = document.querySelector('.element')
const color_of_my_element = your_element.style.color
console.log(color_of_my_element) // red
how to get the value of a style of an element in javascript
to get a property value of an element in js :
html:
<div class="element" style="color: red;">Red hot chili pepper!</div>
js:
const your_element = document.querySelector('.element')
const color_of_my_element = your_element.style.color
console.log(color_of_my_element) // red
how to get the value of a style of an element in javascript
to get a property value of an element in js :
html:
<div class="element" style="color: red;">Red hot chili pepper!</div>
js:
const your_element = document.querySelector('.element')
const color_of_my_element = your_element.style.color
console.log(color_of_my_element) // red
how to get the value of a style of an element in javascript
to get a property value of an element in js :
html:
<div class="element" style="color: red;">Red hot chili pepper!</div>
js:
const your_element = document.querySelector('.element')
const color_of_my_element = your_element.style.color
console.log(color_of_my_element) // red
how to get the value of a style of an element in javascript
to get a property value of an element in js :
html:
<div class="element" style="color: red;">Red hot chili pepper!</div>
js:
const your_element = document.querySelector('.element')
const color_of_my_element = your_element.style.color
console.log(color_of_my_element) // red
how to get the value of a style of an element in javascript
to get a property value of an element in js :
html:
<div class="element" style="color: red;">Red hot chili pepper!</div>
js:
const your_element = document.querySelector('.element')
const color_of_my_element = your_element.style.color
console.log(color_of_my_element) // red
how to get the value of a style of an element in javascript
to get a property value of an element in js :
html:
<div class="element" style="color: red;">Red hot chili pepper!</div>
js:
const your_element = document.querySelector('.element')
const color_of_my_element = your_element.style.color
console.log(color_of_my_element) // red