我的待办事项列表项目在html,css和js是不是交互式的

nkcskrwz  于 2023-02-10  发布在  其他
关注(0)|答案(1)|浏览(126)

这是我的javascript源代码

let addtobutton = document.getElementById("Todo");
let todocontainer = document.getElementById("to-dos");
let inputfield = document.getElementById("inputfield");
addtobutton.addEventListener('click',function()){
    var paragraph = document.createElement('p')
    paragraph.innerText = inputfield.value;
    todocontainer.appendChild(paragraph)
}

我希望添加项目,然后显示在段落中

nvbavucw

nvbavucw1#

将代码替换为

addtobutton.addEventListener('click',function()){}
    • 与**
addtobutton.addEventListener('click',function(){
//here your code
})

let addtobutton = document.getElementById("Todo");
let todocontainer = document.getElementById("to-dos");
let inputfield = document.getElementById("inputfield");
addtobutton.addEventListener('click',function(){
    console.log("hello")
})

相关问题