serialize可以獲取form表單裏面的數值
阿新 • • 發佈:2017-06-03
col user ext pan har nbsp utf-8 div meta 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是鍵的具體名稱 方便調用.
serialize可以獲取form表單裏面的數值