Yekver Yekver - 10 months ago 69
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?


on jQuery 1.6+

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

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