- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.
Example
You can try to run the following code to clear form fields with jQuery −
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $(":reset").css("background-color", "#F98700"); }); </script> </head> <body> <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"> </form> </body> </html>
- Related Articles
- Use HTML with jQuery to make a form
- Bootstrap complex form layout for combined vertical/inline fields with HTML
- Refresh page after clearing all form fields in jQuery?
- How to add form validation for empty input fields with JavaScript?
- How to get and set form element values with jQuery?
- How to add and remove HTML attributes with jQuery?
- How to reset or clear a form using JavaScript?
- Style Input Fields of a form with CSS
- How to validate a form using jQuery?
- How to clear all the input in HTML forms?
- How to clear the canvas using clearRect in HTML?
- How to create a signup form with HTML and CSS?
- How to use FastClick with jQuery Mobile the right way in HTML?
- How to link jQuery in HTML page?
- How to clear all cookies with JavaScript?

Advertisements