Kevin Powell - CommunityKP-C
Kevin Powell - Community13mo ago
17 replies
Kivory

What's wrong with my JS code here?

This is code to make each ".user-message" div that's created test if its font-family is "Roboto", and if it is, to change the font size to 40px.

let paras = document.querySelectorAll('.user-message');

paras.forEach((para) => {
    let compStyles = window.getComputedStyle(para);
    let computedFontFamily = compStyles.getPropertyValue('font-family')
    if (computedFontFamily == "Roboto"){
            para.style.fontSize = "40px";
        }
     }
)

new divs with the ".user-message" tag are created every second. none of them are having their font size changed though when they're created. What's the way to go about this?
Was this page helpful?