Yekver Yekver - 2 years ago 216
MySQL Question

Jquery form get default values

If I have code like this:

<form id="test_form">
<input type="text" value="Original value" />

Then using jQuery I run this code:

$('#test_form input').val('New value');

So input have new value, but I wanna get the old one, so I do:


$('#test_form input').val() == 'Original value';

But reset method reset all form inputs and restore there default values, so how can I restore default value just in definite input?

Answer Source

on jQuery 1.6+

$('#test_form input').prop('defaultValue');

on older versions use .attr() instead of .prop()

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download