0

What is the difference between this?

$("form").serialize();

and this?

var theForm = $("form");
$(theForm[0]).serialize();

How do you get the second sample to serialize like the first one?

3 Answers 3

2

try this:

var theForm = $("form");
theForm.eq(0).serialize();
Sign up to request clarification or add additional context in comments.

Comments

2

First one selects all forms and serializes all form fields.

Second one selects form fields from FIRST form and serializes them

1 Comment

the problem is the second one doesn't serialize the first form.
0

Or you could use in one line:

$("form:first").serialize();

Comments

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.