Search code examples
javascriptjqueryinputrefresh

Refresh page after clearing all form fields (jquery)


Is it possible to refresh the page after clearing all the form fields? Is this a separate function or could it be added to my existing script.

function clear_form_elements(ele) {
 $(ele).find(':input').each(function() {
 switch(this.type) {
    case 'password':
    case 'select-multiple':
    case 'select-one':
    case 'text':
    case 'textarea':
        $(this).val('');
        $(this).removeAttr("style");
        break;
    case 'checkbox':
    case 'radio':
        this.checked = false;
}
});

}

Solution

  • I do not know whether this will work really.But you can do this way as well in jquery :

    $('#PageRefresh').click(function() {
    
                  location.reload();
    
        });
    

    this is rather easy and straight forward.