JQuery: Get original input value

前端 未结 7 1943
面向向阳花
面向向阳花 2021-02-07 01:51

Is it possible to get the initial value of a form input field?

For example:

相关标签:
7条回答
  • 2021-02-07 02:50

    The DOM element has the attribute "value" which you can access by:

    element.getAttribute('value');
    

    ... which may be different from the element's property value.

    Demo

    Note that you may call .setAttribute('value', 'new value') which will actually affect any form.reset() that is called after.

    0 讨论(0)
提交回复
热议问题