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

13th Jul 2022, 1:58 PM
Konda Sandeep
Konda Sandeep - avatar
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 }); });
13th Jul 2022, 2:20 PM
SoloProg
SoloProg - avatar
+ 2
Thank you
13th Jul 2022, 2:26 PM
Konda Sandeep
Konda Sandeep - avatar
0
I tried but it's not working
13th Jul 2022, 2:13 PM
Konda Sandeep
Konda Sandeep - avatar