Why does my input form only clear my value when I use e.target.value="" and not when I use input=""?
Here is what my code looks like that works properly
create: function (e) {
var input = e.target.value;
var val = input.trim();
if (e.which !== ENTER_KEY || !val) {
return;
}
this.todos.push({
id: util.uuid(),
title: val,
completed: false
});
e.target.value="";
this.render();
},
But when I use this code, it doesn't clear the input field. Everything is the same except the 2nd to last line
create: function (e) {
var input = e.target.value;
var val = input.trim();
if (e.which !== ENTER_KEY || !val) {
return;
}
this.todos.push({
id: util.uuid(),
title: val,
completed: false
});
input="";
this.render();
},
When I debugger my code and use input="" it just shows exactly that input="", but when I use e.target.value="" it actually shows what was clicked and then clears it.
I don't get why input="" isn't clearing my input form when my var input = e.target.value??