serialize属性
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6 <script src="../jquery-1.12.2.js"></script> 7 </head> 8 <body> 9 <form action="cccc" id="wenlong"> 10 <input type="text" name="userId"> 11 <input type="text" name="userId1" placeholder="wenlong"> 12 <input type="text" name="userId2"> 13 </form> 14 <button>按钮</button> 15 </body> 16 </html> 17 <script> 18 $('button').click(function(){ 19 $('#wenlong').serialize(); 20 alert($('#wenlong').serialize()); 21 }) 22 </script>
serialize可以获取form表单里面的数据,但是必须是里面的input里面必须有name=”userId”,name是一个键,userId是键的具体名称 方便调用.
转载于:https://www.cnblogs.com/LFxanla/p/6935470.html