我正在尝试根据用户输入创建一个列表。但是我不断收到错误:li.parent 不是函数。如何解决这个问题并创建用户输入结果列表?
这是我尝试过的,我的 html:
<table id="resultTable" cellpadding="1" cellspacing="1" border="1">
<tr>
<th scope="col"></th>
<th scope="col">Hoeveelheid</th>
<th scope="col">Gewicht x KG</th>
</tr>
<tr>
<td>1</td>
<td class="HoeveelheidField"><INPUT TYPE="NUMBER" MIN="0" MAX="10" STEP="1" ></td>
<td class="GewichtField"><INPUT TYPE="NUMBER" MIN="0" MAX="10" STEP="1" ></td>
</tr>
<tr>
<td>2</td>
<td class="HoeveelheidField"><INPUT TYPE="NUMBER" MIN="0" MAX="10" STEP="1" ></td>
<td class="GewichtField"><INPUT TYPE="NUMBER" MIN="0" MAX="10" STEP="1" ></td>
</tr>
<tr>
<td>3</td>
<td class="HoeveelheidField"><INPUT TYPE="NUMBER" MIN="0" MAX="10" STEP="1" ></td>
<td class="GewichtField"><INPUT TYPE="NUMBER" MIN="0" MAX="10" STEP="1" ></td>
</tr>
</table>
</div>
<button onclick ="window.location.href = '#close';getData(); writeData(); " href="#close" id="submitButton" class="tester2"> Submit </button>
<p>
<ol id ="exerciseList">
</ol>
</p>
我的JS:
const exerciseName = document.getElementById("exercise-search");
function gotData(data){
//console.log(data.val());
var exercise = data.val();
console.log(exercise);
console.log(exercise.hoeveelheidKilogram);
exercise.repetitie.forEach(function getReps (value) {
console.log(value);
});
exercise.hoeveelheidKilogram.forEach(function(value) {
console.log(value);
});
for (var i = 0; i < HoeveelheidArr.length; i++) {
var li = document.createElement('li',exerciseName.value );
li.parent('exerciseList');
}
}
幕布斯6054654
相关分类