JavaScript – Change the Font Weight of HTML Element
To change the font weight of a HTML Element using JavaScript, get reference to this HTML Element element, and assign required font weight value to the element.style.fontWeight
property.
In the following example, we will change the font weight of HTML Element with id "myElement"
to "600"
, in JavaScript, using element.style.fontWeight
property.
example.html
ADVERTISEMENT
Conclusion
In this JavaScript Tutorial, we learned how to change the font weight of a HTML Element using JavaScript.