Skip hidden inputs in Jquery serialize

后端 未结 4 1678
无人及你
无人及你 2021-01-12 18:09

I have forms with inputs of hidden and visible like below.In this example I want to serialize only name=\'country\' which is not hidden

4条回答
  •  离开以前
    2021-01-12 18:52

    You can make a temporary copy of it and remove the hidden inputs from it before serializing :

    var form = $("#finalform").clone();
    $(form).find("input[type=hidden]").remove()
    var serialized = $(form).serializeArray();
    

提交回复
热议问题