自定义一个序列化表单的方法
2016-09-29 16:22
134 查看
/** 自定义一个序列化表单的方法* */ $.fn.serializeObject = function() { var o = {}; $(this).find("input").each(function(index) { if ($(this).attr("name") != undefined) { if ($(this).attr("type") == "text" || $(this).attr("type") == "password" || $(this).attr("type") == "hidden") { o[$(this).attr("name")] = $(this).val(); //alert($(this).attr("name")+" : "+$(this).val()); } if ($(this).attr("type") == "radio") { if ($(this).is(":checked")) { o[$(this).attr("name")] = $(this).attr("value"); } } if ($(this).attr("type") == "checkbox") { if ($(this).is(":checked")) { o[$(this).attr("name")] = $(this).attr("value"); } } } }); $(this).find("select").each(function(index) { if ($(this).attr("name") != undefined) { o[$(this).attr("name")] = $(this).val(); } }); $(this).find("textarea").each(function(index) { if ($(this).attr("name") != undefined) { o[$(this).attr("name")] = $(this).val(); } }); return o; };
相关文章推荐
- 自定义一个序列化表单的方法2+提示语
- 一个自定义的json序列化对象的方法
- jquery将一个表单序列化为一个对象的方法
- jquery将一个表单序列化为一个对象的方法
- 一个流行且实用的JS表单验证提示,演示了怎么自定义错误信息的显示方式,同时通过写FormValid.showError类方法来实现错误显示方式自定义: errMsg 是一个错误消息的数组,这样方便自定
- jQuery Validate 表单验证插件----自定义一个验证方法
- jquery将一个表单序列化为一个对象的方法
- jquery将一个表单序列化为一个对象的方法
- 关于自定义URL协议的方法 DOwn一个(3)
- 秀一个做的BS的自定义表单(类似INFOPATH)
- asp.net中用户自定义控件调用另外一个用户自定义控件中的方法
- 分享一个对象序列化为XML和反序列化的扩展方法
- 关于自定义URL协议的方法 DOwn一个(2)
- python Json的一点收获,自定义序列化方法
- 一个php页面处理两个form表单的方法
- 手把手教你自己写一个js表单验证框架的方法
- 所有的页面都继承自定义的BasePage,而有一个特殊页面要继承BasePage,但不想执行父类构造函数调用的某些方法,怎么办?
- javascript中alert函数的替代方案,一个自定义的对话框的方法(引用)
- javascript中alert函数的替代方案,一个自定义的对话框的方法
- Drupal中关于表单form的drupal_get_form方法如何传递自定义参数