通知短信+运营短信,5秒速达,支持群发助手一键发送🚀高效触达和通知客户 广告
# 序列号表单为JSON对象 > 前提是先需要引入`jquery` ``` /** * 序列化为对象 */ $.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; } ``` 使用方法 ``` <form id="demo"> 用户名:<input name="user" value="root" /> 密码: <input name="pwd" value="123456" /> </form> ------------- let data = $('#demo').serializeObject(); ------------- data为结果: { "user":"root", "pwd":"123456" } ``` > 注意: disabled="" 属性的不会加入对象中