<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>jQuery input[type="radio"] 表单提交</title> <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script> </head> <body> <form id="form1" οnsubmit="return false" action="#" name="form1"> <label for="gender">女</label><input id="gender" type="radio" name="gender" value="女" checked><br> <!-- <input type="submit" value="提交" οnclick="f();">--> <input type="image" src="https://www.runoob.com/try/demo_source/img_submit.gif" alt="Submit" width="48" height="48" οnclick="f();" title="确定"> </form> <script> /*参考:https://www.runoob.com/tags/att-input-type.html * 1.type="radio" * 1.type="image"(定义图像作为提交按钮)。*/ function f() { /*提交函数。*/ let data = $('#form1').serialize(); console.log("data:", data); // data: gender=%E5%A5%B3 let value = data.slice(data.lastIndexOf('=') + 1); console.log("value:", value); // value: %E5%A5%B3 let val_raw = decodeURIComponent(value); console.log("val_raw:", val_raw); // val_raw: 女 } </script> </body> </html>
jQuery input[type=“radio“] 表单提交.html
最新推荐文章于 2024-06-11 10:54:21 发布