kangyuanjiang

//表单序列化成JSON对象
$.fn.serializeObject = function () {
var o = {};
var a = this.serializeArray();
$.each(a, function () {
if (o[this.name]) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || \'\');
} else {
o[this.name] = this.value || \'\';
}
});
return o;
}

//调用方式

  var data = $(".layui-form").serializeObject();

data 就是JS对象了

分类:

技术点:

相关文章:

  • 2021-07-31
  • 2021-08-02
  • 2021-10-14
  • 2021-12-23
  • 2021-08-02
  • 2021-12-23
  • 2022-03-04
猜你喜欢
  • 2021-12-23
  • 2021-08-02
  • 2022-02-13
  • 2021-08-02
  • 2021-12-23
相关资源
相似解决方案