4

I have a form with some inputs, selects, and checkboxes. I am unable to exclude the items with class "not_included" in my serialized Array.

var dataArray = $("#split_form").not(".not_included").serializeArray();

This still is serializing the fields with class "not_included".

Thanks!

626
  • 1,159
  • 2
  • 16
  • 27

1 Answers1

3

To filter the <input>s within the <form>, you'll have to first find a collection of them:

$('#split_form').find(':input').not('.not_included').serializeArray();

// or
$('#split_form').find(':input:not(.not_included)').serializeArray();

.not() only applies filtering to the elements directly within the jQuery() collection, which is presumably just the <form> based on the selector, '#split_form'.

It won't affect their children or descendants. So, it's just determining whether the <form> is either:

<form id="split_form"></form>
<form id="split_form" class="not_included"></form>
Jonathan Lonowski
  • 121,453
  • 34
  • 200
  • 199