There is a simple Js script to change whole website font?

122 Views Asked by At

I can’t find a simple JavaScript script ton change the font family of my website. I use a cookie plugin in wordpress and I search a script for when users don’t accept cookies. Thanks for your help !

I’m a beginner in JavaScript but I know the element.style.fontFamily but not to set it.

1

There are 1 best solutions below

0
Valerio Porporato On
const element = document.querySelector('#your-element');
const yourFont = 'sans-serif';
element.style.fontFamily = yourFont;

Change element and yourFont as you need.