Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
I want to change the font-family of all elements in a document with JavaScript. I have tried this: document.querySelectorAll("body").forEach( (e)=>{ e.style.fontFamily = "arial"; }); ...
Question
javascript
#3: Post edited
Change font-family of all elements with JavaScript
- Change font-family with JavaScript
#2: Post edited
Change font-family with JavaScript
- Change font-family of all elements with JavaScript
I want to change the `font-family` of all elements in a document with JavaScript. I have tried this: ```js document.querySelectorAll("body").forEach( (e)=>{ e.style.fontFamily = "arial"; }); ``` This changed the font-family of generally everything besides what already had a `font-family` defined in CSS ID or class. How could I make the JavaScript command to "run through" these IDs and classes?
#1: Initial revision
Change font-family with JavaScript
I want to change the `font-family` of all elements in a document with JavaScript. I have tried this: ```js document.querySelectorAll("body").forEach( (e)=>{ e.style.fontFamily = "arial"; }); ``` This changed the font-family of generally everything besides what already had a `font-family` defined in CSS ID or class. How could I make the JavaScript command to "run through" these IDs and classes?