开发者

jQuery Object Serialize

开发者 https://www.devze.com 2023-04-09 16:34 出处:网络
What is the difference between this? $(\"form\").serialize(); and this? var theForm = $(\"form\"); $(theForm[0]).serialize();

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?


try this:

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


First one selects all forms and serializes all form fields.

Second one selects form fields from FIRST form and serializes them


Or you could use in one line:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消