此问题在此处已有答案:
How to get the pure text without HTML element using JavaScript?(10个答案)
Why does jQuery or a DOM method such as getElementById not find the element?(6个答案)
3天前关闭。
这里是html内容
<div id="result-box" class="col-5">
<h3 class="result" id="name" >Name: --- </h3>
<h3 class="result" id="age">Age: ---</h3>
<h3 class="result" id="class">Class: --- </h3>
<h3 class="result" id="skill">Skill:--- </h3>
<h3 class="result" id="gen">Gender: --- </h3>
<h3 class="result" id="perform">Perfomance: --- </h3>
</div>
这是js代码你告诉我这里面有什么错误
let name = document.getElementById('name').value;
let age = document.getElementById('age').value;
let class = document.getElementById('class').value;
let skil = document.getElementById('skill').value;
let gen = document.getElementById('gen').value;
let perform = document.getElementById('perform').value;
let name = document.getElementById('name').value
console.log(name)
在控制台面板中显示未定义,这背后的原因是什么,请指导
2条答案
按热度按时间wqnecbli1#
9njqaruj2#
你犯了几个错误,可能会导致你的行为: