Does an input have an "original value" attribute?

attributes, default-value, html-input, javascript, jquery

Solution

You can use the input element's `defaultValue` property

For example:

$('#input')[0].defaultValue

Note how by treating the jQuery object as an array we are able to directly access the DOM node and its native property.

See jsFiddle demo

Problem

With the latest changes to jQuery there are the different methods, `.prop()` `.attr()`. What I am wondering is if there is a way to get the original value of the input when the page was loaded? I know I could do: ``` $('#input').data('originalValue', $('#input').val()); ``` and then I can refer to it through ``` $('#input').data('originalValue'); ``` But I thought that since I can say, find out the original checked state of a checkbox I thought maybe there is something similar for the value?

Original source

Related problems