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

150
Visualizações
Displaying JavaScript variable inside div fails

I want to display my JavaScript variable inside div col. I just can't get it displayed. Even with inspector it doesn't have a value. However, if I display it outside of every div, so in the beginning of the page it works..

$(document).ready(function() {
  var firma = "test d.o.o.";
  document.getElementById("insert").innerHTML = firma;
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div>
  <p><span style="z-index: 9999 !important;" id="insert"></span></p>
</div>

Here is code: http://jsfiddle.net/th5wydn1/10/

Thank you for your help. Greetings

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

0

If all you did is copy and paste the code, your local page doesn't have jQuery.

Either add that, or replace your one line of jQuery code with native Javascript:

document.addEventListener('DOMContentLoaded', function() {
  var firma = "test d.o.o.";
  document.getElementById("insert").innerHTML = firma;
});
about 4 years ago · Juan Pablo Isaza Relatório

0

You are using jquery Syntax. Means you need include the JQuery Lib. For example add this CDN script link above your closing body tag.

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

$(document).ready(function() {
  var firma = "test d.o.o.";
  document.getElementById("insert").innerHTML = firma;
});
<div>
  <p><span style="z-index: 9999 !important;" id="insert"></span></p>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div>
  <p><span style="z-index: 9999 !important;" id="insert"></span></p>
</div>

about 4 years ago · Juan Pablo Isaza Relatório

0

Hello change "insert" word , maybe this keyword,or busy

<span style="z-index: 9999 !important;" id="_insert"></span>


$().ready(function() {
            const firma = "TEST";
            document.getElementById("_insert").innerHTML = firma;
        });

http://jsfiddle.net/vc75dmnx/

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