form-serialize-serializeArray-submit
作者:互联网
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>attr-prop</title>
<style> </style> </head> <body> <!-- 1 serialize()
2 serializeArray()
3 submit()
--> <form method="post"> <input type="text" name="val" value="kobe"> <input type="password" name="pw" value="123"> <input type="checkbox" checked="checked" name="rember"> <input type="submit" value="按钮" name="anniu"> </form>
<script src="../zepto.js"></script> <script src="../touch.js"></script> <script> $(function(){ var result = $('form').serialize() console.log(result); // val=kobe&pw=123&rember=on
result = $('form').serializeArray() // (3) [ {name: "val", value: "kobe"} {name: "pw", value: "123"} {name: "rember", value: "on"}length: 3__proto__: Array(0) console.log(result);
$('form').submit(function(event){ event.preventDefault() alert('1') }) }) </script>
</body> </html>
<style> </style> </head> <body> <!-- 1 serialize()
2 serializeArray()
3 submit()
--> <form method="post"> <input type="text" name="val" value="kobe"> <input type="password" name="pw" value="123"> <input type="checkbox" checked="checked" name="rember"> <input type="submit" value="按钮" name="anniu"> </form>
<script src="../zepto.js"></script> <script src="../touch.js"></script> <script> $(function(){ var result = $('form').serialize() console.log(result); // val=kobe&pw=123&rember=on
result = $('form').serializeArray() // (3) [ {name: "val", value: "kobe"} {name: "pw", value: "123"} {name: "rember", value: "on"}length: 3__proto__: Array(0) console.log(result);
$('form').submit(function(event){ event.preventDefault() alert('1') }) }) </script>
</body> </html>
标签:value,serialize,name,form,serializeArray,submit,result 来源: https://www.cnblogs.com/eric-share/p/15905745.html