How can I get the form value from a disabled <input> element

后端 未结 10 1468
小鲜肉
小鲜肉 2020-12-04 23:50

The HTML standard for forms appears to be such that disabled input elements do not contribute to the form name/value collection.

Is there ANY way to get around this?

10条回答
  •  北荒
    北荒 (楼主)
    2020-12-05 00:31

    You can easily

    1. Change status to normal (disabled=false)
    2. Read Value
    3. reset input status to disabled

      $(element).prop("disabled", false); var text = $(element).val(); $(element).prop("disabled", true)
      

提交回复
热议问题