Guy will depend a little on how you set up your CSS as a whole, but you can add a class to body
with a new font-family
, and with that everything inside will inherit this new font-family
of the class added in body
This example is with jQuery, and when you click on BTN
he adds the class .fonte
in the body
with the font-family
new.
$( "#btn" ).click(function() {
$("body").toggleClass("fonte");
$(this).toggleClass("ativo");
});
body {
font-family: 'Times New Roman', Times, serif;
}
body.fonte {
font-family: arial;
}
#btn.ativo {
background-color: green;
}
#btn {
background-color: red;
cursor: pointer;
}
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<div id="btn">btn</div>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Recusandae quibusdam nostrum, eveniet ullam voluptas blanditiis quos unde pariatur maiores quasi laudantium modi dolorem officia, corporis distinctio doloribus molestias ipsa autem.</p>
The whole body? This is a lot, it is possible to do but it would not be a very "elegant" thing. I suggest you continue studying Js and when you have a good base start studying the Javascript Framework, such as Angular for example.
– markim
But you want to change styles or html itself ?
– Isac