一旦输入命中,我无法弄清楚如何能够删除输入框中的内容。如果您能提供有关哪些代码及其所属位置的信息将非常有用。
//代码在这里
$('ul').on('click', 'li', function (){
$(this).toggleClass('completed');
});
$('ul').on('click', 'span', function(events){
$(this).parent().remove();
});
$('input').keypress(function cleartext(event){
if(event.which === 13) {
var todoItem = $(this).val();
$('ul').append(
"<li>" +
"<span>" +
"<i class='fa fa-times'></i>" +
"</span>" +
todoItem +
"</li>"
);
}
});
答案 0 :(得分:0)
$('input').keypress(function cleartext(event){
if(event.which === 13) {
var todoItem = $(this).val();
$(this).val('');//this will clear the contents
$('ul').append(
"<li>" +
"<span>" +
"<i class='fa fa-times'></i>" +
"</span>" +
todoItem +
"</li>"
);
}
});