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

134
Visualizações
Is there a way to directly style text content generated in JavaScript?

I'm building a tic-tac-toe game, and built the squares of the gameboard with p HTML elements. Whenever a square is clicked on, I'm running a function that takes a variable of turn, which is equal to 'X', and inserts it into the square when the square is clicked on. The function also toggles the variable's text, so 'O' is next.

Is there a way to directly style these 'X's and 'O's? I've tried to style the p elements color and font-size, and this worked, but now I'm trying to style the position of the 'X's and 'O's within the square.

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

0

You can add the classes to your CSS file and then add them to the corresponding elements.

An example:

let elementX = document.getElementById("element_x");

elementX.classList.add("element_x_class");
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