0
How to clear the text input field using Jquery
I'm creating a to-do list application after taking input i want to clear the input filed https://code.sololearn.com/WeEMcXx833xG/?ref=app
3 Answers
+ 2
// In JS
var notes_list = $("#demo");
var btn = $("#submit_btn");
var note = $("#note");
$(function() {
btn.click(function () {
if(note.val() == "") return;
var note_elem = $("<li></li>").text(note.val());
note_elem.append("<button class='remove'>X</button>")
notes_list.append(note_elem);
$(".remove").click( function() {
$(this).parent().remove();
});
note.val(''); // to clear the text
});
});
+ 2
Thank you
0
I tried but it's not working