0

I got something like that:

<form id="my_form">
<input type="hidden" name="name_1" value="1">
<input type="text" name="name_2" value="text_1">
<input type="text" name="name_3" value="text_2">
<select name="name_4">
    <option value="1">opt1</option>
    <option value="2">opt2</option>
</select>
</form>

and in my jQuery code:

$('#my_form').serializeArray().forEach(function(item){
  // here 'item' has two props: 'name' and 'value'
  // how can I select form's item based on name but NOT type HIDDEN ?
});

3 Answers 3

1

You can use :not()

Change Your selector as

$('#my_form :not(:hidden)').serializeArray().forEach(function(item){
  // here 'item' has two props: 'name' and 'value'
  // how can I select form's item based on name but NOT type HIDDEN ?
});

DEMO

Sign up to request clarification or add additional context in comments.

Comments

0
$('#my_form').find("input[type!='hidden']").serializeArray().forEach(function(item){
  // here 'item' has two props: 'name' and 'value'
  // how can I select form's item based on name but NOT type HIDDEN ?
});

Comments

0

You can use jQuery not selector:

Selects all elements that do not match the given selector.

Code:

$('#my_form :not([type=hidden])').serializeArray().forEach(function(item){

});

Demo: http://jsfiddle.net/5gygs/

1 Comment

Why not using '.each()' instead of serializeArray?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.