Site Builder Studio

SITEBUILDERSTUDIO

Clear form inputs with jQuery

jQuery doesn’t have function for clearing forms, but there is a way.

With this method you can clear form inputs with jQuery by re-loading the form.


<div id="container">
    <div id="content">
        <?php include("myform.php"); ?>
    </div>
</div>

$("#container").load("#content");

When the jQuery loads the content div into the container div, the file myform.php will essentially be refreshed and the form inputs will be cleared. This has been a neat trick to clear form inputs with jQuery.