Javascript and defaultValue of hidden input elements

后端 未结 2 1086
轻奢々
轻奢々 2021-01-04 01:29

Assume you have input element:


Then launch js script:

var e =          


        
2条回答
  •  心在旅途
    2021-01-04 01:56

    The "defaultValue" property is only maintained in a way you apparently expect for "text", "file", and "password" fields.

    Here is the relevant portion of the DOM spec.

    I suspect the reason for this is that user activity on its own cannot change the value of hidden elements. If you want to preserve the initial values, run something at "load" or "ready" to stash the value somewhere.

提交回复
热议问题