Search code examples
jquerytextbox

easiest possible way to clear values of all controls in a div using jquery?


I have an add form inside a div which has 3-5 textboxes.. I submit the form via ajax and hide the div in the success function of it... Now i want to clear all the values of textboxes within the adddiv using jquery?


Solution

  • If they're just text boxes (<input type="text"> fields), then $("form :input").val(""); would be the easiest way. If you have multiple types of inputs, though, you should check this out.

    http://www.learningjquery.com/2007/08/clearing-form-data

    It walks through how to create a plugin for clearing forms.