jQuery 仅序列化 div 中的元素 [英] jQuery to serialize only elements within a div

查看:8
本文介绍了jQuery 仅序列化 div 中的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得与 jQuery.serialize() 相同的效果,但我只想返回给定 div 的子元素.

I would like to get the same effect as jQuery.serialize() but I would like to return only the child elments of a given div.

示例结果:

single=Single2&multiple=Multiple&radio=radio1

推荐答案

没问题.只需使用以下内容.这将与序列化表单完全一样,但使用 div 的内容.

No problem. Just use the following. This will behave exactly like serializing a form but using a div's content instead.

$('#divId :input').serialize();

查看 https://jsbin.com/xabureladi/1 以获取演示(https://jsbin.com/xabureladi/1/edit 代码)

Check https://jsbin.com/xabureladi/1 for a demonstration (https://jsbin.com/xabureladi/1/edit for the code)

这篇关于jQuery 仅序列化 div 中的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆