序列化表单的字段集内容

发布于 2024-11-19 00:47:04 字数 434 浏览 6 评论 0原文

这是我的代码: http://jsfiddle.net/michelejs/Pt6LQ/25/

我将仅序列化字段集名称= cap1。

所以我尝试修改

$('#result').text(JSON.stringify($('form').serializeObject()));

        $('#result').text(JSON.stringify($('fieldset#cap1').serializeObject()));

但它不起作用并返回我{}。 如何修改代码以仅序列化一个字段集内容而不是所有表单?

多谢。

this is my code: http://jsfiddle.net/michelejs/Pt6LQ/25/

I would to serialize only the fieldset name= cap1.

So I tried to modify

$('#result').text(JSON.stringify($('form').serializeObject()));

in

        $('#result').text(JSON.stringify($('fieldset#cap1').serializeObject()));

but it doesn't work and return me {}.
How can I modify the code for serialize only one fieldset content and not all the form?

Thanks a lot.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

贱人配狗天长地久 2024-11-26 00:47:04

您应该使用:

 $('fieldset#cap1 input').serializeObject()));

更新的小提琴:

http://jsfiddle.net/Pt6LQ/26/

You should use:

 $('fieldset#cap1 input').serializeObject()));

updated fiddle:

http://jsfiddle.net/Pt6LQ/26/

扛起拖把扫天下 2024-11-26 00:47:04

当你使用 #cap1 时,它应该是 id 而不是 name

as you use #cap1, it should be id instead of name

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文