[英]insertAdjacentHTML is not a function in todolist
I was making my first pure Js project of todolist. 我正在制作我的第一个纯粹的Js项目的todolist。 I want when user adds an item in the list it gets it placed at the list. 我想当用户在列表中添加项目时将其放置在列表中。 I was using this code I saw in a tutorial but it gives an error. 我正在使用我在教程中看到的代码,但它给出了一个错误。
It gives an error: jeep.insertAdjacentHTML is not a function
它给出了一个错误: jeep.insertAdjacentHTML is not a function
Here is the markup: 这是标记:
<section class="listContent">
<div class="container">
<ul class="list" id="deep">
<li style="text-align: center" id="itemList">
<!-- < i class="fa fa-circle-o pull-left" id = "circle" aria - hidden="true" > </i>
<p class="text" > DRINK COFFEE < /p>
<i class="fa fa-trash pull-right" id = "delete" aria - hidden="true" > </i> -->
</li>
</ul>
</div>
</section>
Here is the JS 这是JS
const date = document.getElementById("date");
const jeep = document.getElementById("deep");
const items = document.getElementById("itemList");
function addToDo(todo) {
const item =
`<i class="fa fa-circle-o pull-left" job="complete" id="circle" aria-hidden="true"></i>
<p class="text"> ${todo}</p>
<i class="fa fa-trash pull-right" id="delete" job="delete" aria-hidden="true"></i>
` ;
const position = "beforeend";
console.log(item);
console.log(position);
jeep.insertAdjacentHTMl(position, item);
}
addToDo("drink coffe");
first try .insertAdjacentHTML
- the L should be capitalized. 首先尝试.insertAdjacentHTML
- L应该大写。 Also it looks like in the HTML markup that element lives inside of the <li>
no adjacent to it. 此外,在HTML标记中,该元素位于<li>
内部,与其相邻。 It looks like you might want to use .appendChild()
on the <ul id="deep"></ul>
看起来你可能想在<ul id="deep"></ul>
上使用.appendChild()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.