使用getElementById.innerHTML只是这样一个简单的问题:
document.getElementById('example').innerHTML = fullName;
它根本不起作用。我知道它非常简单,但我不知道它是如何工作的。
我也尝试过innerText
。
组成是这样的:
./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;