龙空技术网

jqurey获取表单所有数据

叶斌兵 503

前言:

现时我们对“js获取form数据”大概比较重视,大家都需要分析一些“js获取form数据”的相关知识。那么小编同时在网上搜集了一些对于“js获取form数据””的相关文章,希望朋友们能喜欢,我们一起来学习一下吧!

<!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= ybb00000 & 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="ybb" disabled="">        <!---  title=&password=&interest=1&sex=0&like1%5Bwrite%5D=on&like1%5Bread%5D=on  -->    </form></body></html>

标签: #js获取form数据