jQuery: Clear All Text Fields (with one line of code)


/ Published in: jQuery
Save to your folder(s)

This can come in handy for a reset or cancel button. You can clear all inputs within a single div in one line of code. Pretty sexy.


Copy this code and paste it in your HTML
  1. // "inputfields" is the id of the div that contains the text fields.
  2.  
  3. $('div[id=inputfields] input[type=text]').val("");

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.