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

查看:325
本文介绍了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();

检查 http://jsbin.com/azodo 以进行演示(

Check http://jsbin.com/azodo for a demonstration (http://jsbin.com/azodo/edit for the code)

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

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