Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

156
Visualizações
How would one successfully change the font of a header/paragraph in javascript?

Hope you're having a great day. I'm trying to make my site more accessible, but I really love this one font. However, it's hard to read for some people. I'm making a button to change all the fonts to an easier to read font, but I'm having trouble creating that code.

I've tried document.getElementById('header').style.fontFamily = "font-family: 'Rambla', sans-serif" (and all of the other DOM selectors there too), But they either don't work with no errors, or it errors.

Here's a snippet of my code:

function fontChange() {
  document.getElementById('header').style.fontFamily = "font-   family: 'Rambla', sans-serif"
  console.log('Works?')
}
<h1 id="header">What are the parameters for the /scheme command?</h1>
<button id="fontChange" onclick="fontChange()">
  🦽
</button>

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I advice you to toggle a global class on body element for example.

document.body.classList.add('accessible-font');

Then it would give you more possibilities and easier integration using some stylesheets :

.accessible-font #header {
  font-family: 'Rambla', sans-serif";
}

You can then define some global or specific rules based on this global class. It also allows you to easilly switch between a11y ON / OFF.

about 4 years ago · Juan Pablo Isaza Relatório

0

try this ?

    <h1 id="header">What are the parameters for the /scheme command?</h1>
<button id="fontChange" onclick="fontChange()">
  🦽
</button>
<script>
    function fontChange() {
           document.getElementById('header').style.fontFamily = "Rambla"
        console.log('Works?')
    }
</script>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda