0

I just have a simple problem using getElementById.innerHTML like this:

document.getElementById('example').innerHTML = fullName;

Its not working at all. I know its pretty simple but I do not know how its not working.

I've also tried innerText.

The composition is like this:

./index.js 
./index.html

html:

<!DOCTYPE html>
<html lang="en">
<head>
    <script src="index.js"></script>
    <title>JS Course</title>
</head>
<body>
    <p id="example"></p>
</body>
</html>

index.js

let word = 'Michal'
let word1 = 'Ruzicka'

const fullName = `${word} ${word1}`

console.log(fullName);

document.getElementById('example').innerHTML = fullName;
DjaouadNM
  • 22,013
  • 4
  • 33
  • 55
Michalistico
  • 185
  • 3
  • 13
  • You might want to try looking at the console in the developer tools where there will be an error message that gives you a clue about why it isn't working. – Quentin Sep 04 '19 at 11:07
  • It doesnt says anything. But putting the script tag at the end of the body section worked! Somehow.. Thank you all! – Michalistico Sep 04 '19 at 11:55

0 Answers0