Excluding certain inputs on serialize

前端 未结 6 1172
长发绾君心
长发绾君心 2020-12-29 20:05

I am trying to exclude an input by name (it is a hidden input holding my nonce)

The following question is almost what I am looking for:

How do I use jQuery&#

6条回答
  •  佛祖请我去吃肉
    2020-12-29 20:20

    I am not happy with 'input[name!=security]' because it exclude all other input type like select,.. You can add them manually but this list just keep increasing with new HTML tags. So with every new tag coming, your code is broken again.

    Here is my solution:

    $form.find(':not(input[name=draft])').serialize()
    

    or

    $('form[name=expenses] :not(input[name=draft])').serialize()
    

    Space is very important in second example.

提交回复
热议问题