CSS styles in JavaScript (setting and getting) - Beau teaches JavaScript
FBTwitterReddit
video description
Rating: 4.0; Vote: 1
How to set CSS properties and styles in JavaScript. Also how to get CSS.
This video covers style, cssText, setAttribute, and getComputedStyle.
- Code: https://codepen.io/beaucarnes/pen/EmVmbZ?editors=1010
- Resource: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Properties_Reference
- Beau Carnes on
The: I know this is JavaScript, but having to toggle a class is easy using jQuery: $(#attribute).css(-background-, blue); That being said, I didnt know about setAttribute and I cant wait to use it. Thanks for the great series on JavaScript! Date: 2022-03-14