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

421
Visualizações
How to print a variable's value in HTML, similar to console.log()

If the title is not clear...I have BIG function, and I want to see the value of a variable partway through its execution on the webpage... very similar to console.log(). Is there a method to capture that and display it in the HTML ? Thanks.

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

0

I think you can achieve it with generator functions

about 4 years ago · Juan Pablo Isaza Relatório

0

The answer has been found, have attached it below ! Thanks everybody.

console.log = function(message) {
    document.getElementById('result').innerHTML = message;
};
console.log('I love Panda');
<div id="result"></div>

about 4 years ago · Juan Pablo Isaza Relatório

0

If you want to show something similar to console.log() inside the HTML, you can just create a div on the page and then put whatever you want to view inside the div. Something like this:

<div id="test"></div>

<script>
  const x = "1234";
  document.getElementById('test').innerHTML = x;
</script>

This page has some info on how to display the contents of objects and arrays in HTML. https://www.w3schools.com/js/js_object_display.asp

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