ancy ancy - 2 months ago 7
HTML Question

Clear all fields in a form whenever hit back button

I used below code to reset all fields data whenever user hit back button.It is working perfectly on firefox but not in chrome.

Here is my code:

$(window).load(function() {
$('form').get(0).reset(); //clear form data on page load
});

Answer

Try this, it should work on chrome

$('form').trigger("reset");

instead of

$('form').get(0).reset();