jq 获取表单所有数据
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <script src="jquery-3.2.1.min.js"></script> <!--<link href="layui/css/layui.css" rel="stylesheet" /> <script src="layui/layui.all.js"></script>--> <script> $(function () { $("#tj").click(function () { console.log("xxx"); console.log($("form").serialize()); //输出字符串 console.log($("form").serializeArray()); //输出数组 }) }) </script> </head> <body> <input type="button" value="tets" id="tj"/> <form class="layui-form layui-form-pane" action=""> <input type="text" name="title" autocomplete="off" placeholder="请输入标题" class="layui-input"> <input type="password" name="password" placeholder="请输入密码" autocomplete="off" class="layui-input"> <select name="interest"> <option value="">---</option> <option value="0">000</option> <option value="1" selected="selected">111</option> <option value="2">222</option> <option value="3">333</option> <option value="4">444</option> </select> <!--//title= amdin & password= admin888 & interest= 4 输出字符串--> <!-- [{…}, {…}, {…}] 输出数组 对象 --> <input type="radio" name="sex" value="0" title="男" checked="checked"> <input type="radio" name="sex" value="1" title="女"> <!-- title=&password= & interest=1 & sex=0 --> <input type="checkbox" name="like1[write]" lay-skin="primary" title="写作" checked=""> <input type="checkbox" name="like1[read]" lay-skin="primary" title="阅读"> <input type="checkbox" name="like1[game]" lay-skin="primary" title="游戏" disabled=""> <!--- title=&password=&interest=1&sex=0&like1%5Bwrite%5D=on&like1%5Bread%5D=on --> </form> </body> </html>