How to clear HTML form fields with jQuery?

With jQuery, you can easily clear HTML form fields. For this, jQuery: reset Selector is used. This will clear the HTML form fields.


You can try to run the following code to clear form fields with jQuery −

Live Demo

<!DOCTYPE html>
      <script src=""></script>
            $(":reset").css("background-color", "#F98700");
      <form action="">
         Student Name<br><input type="text" name="sname"><br>
         Student Subject<br><input type="password" name="ssubject"><br>
         <input type="submit" value="Submit"><br>
         <input type="reset" value="Reset">

Updated on: 17-Jun-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started