<form id="formDemo" class="layui-form"> <table class="layui-table" lay-even> <colgroup> <col width="100"> <col width="200"> <col> </colgroup> <tbody> <tr> <th>用户名</th> <td id="userName"> <div class="layui-form-item layui-input-inline"> <input tyep="text" name="userName" class="layui-input"> </div> </td> </tr> <tr> <th>登录密码</th> <td id="password"> <div class="layui-form-item layui-input-inline"> <input tyep="text" name="password" class="layui-input"> </div> </td> </tr> </tbody> </table> </form>
<script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="jquery.serializejson.js"></script><script type="text/javascript"> function getUser(){ console.log($('#formDemo').serializeJSON()); console.log(JSON.stringify($('#formDemo').serializeJSON())); return JSON.stringify($('#formDemo').serializeJSON()); } </script>来源:https://www.cnblogs.com/makexu/articles/6377617.html