JQuery: Get original input value

前端 未结 7 2030
面向向阳花
面向向阳花 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:38

    Input element got property called defaultValue that is storing the original value.

    To reach it via jQuery, just use .prop():

    var value = $(this).prop("defaultValue");
    

    Updated jsFiddle - after changing to "two", the above will return "one".

提交回复
热议问题