I am trying to do a web app similar to google calendar.(我正在尝试做一个类似于Google日历的网络应用。)
I have done the object and methods within it but now it's time to be able to add what I want as a task.(我已经完成了其中的对象和方法,但是现在是时候可以添加我想要的任务了。) My idea is for the user to add something to the input and that input being console.logged for now.(我的想法是让用户向输入中添加一些内容,并且此输入现在为console.logged。)
Any idea?(任何的想法?)
HTML(的HTML)
<div class="new-task" id="task-input">
<div id="add-new-task">Task: <input type="text"></div>
<div id="add-time">Time: <input type="text"></div>
<button class ="save-task" onclick="">Save task</button>
</div>
Javascript(Java脚本)
var idCounter = 0
var tasksManager = {
array: [],
add: function(task){
taskObject = {
title: task,
idVerification: idCounter ++
}
tasksManager.array.push(taskObject)
},
show:function(id){
var i;
for (i = 0; i < tasksManager.array.length; i++) {
if(id === tasksManager.array[i].idVerification){
return tasksManager.array[i]
}
}
},
delete:function(task){
if(this.show){
tasksManager.array.splice(task)
}
}
}
var newTask = document.getElementById("add-new-task")
newTask.addEventListener('click',tasksManager.add())
console.log(tasksManager.array)
As you can see with console.log above the array index [0] is logged as undefined but I wanted the user to write in the input " Go to the gym" and this to be logged within the array.(如在console.log上面看到的那样,数组索引[0]被记录为未定义,但我希望用户在输入中输入“ Go to the Gym”,并将其记录在数组中。)
Thanks(谢谢)
ask by Rpx translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…