Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

147
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!