代碼:this
<script> $(function() { $('#submit').click(function() { var d = {}; var t = $('form').serializeArray(); $.each(t, function() { d[this.name] = this.value; }); alert(JSON.stringify(d)); }); }); </script> <form> <input id="a1" type="input" value="" name="a1"><br> <input id="a2" type="input" value="" name="a2"><br> <input id="a3" type="input" value="" name="a3"><br> <input id="a4" type="input" value="" name="a4"><br> <select id="ax" name="ax"> <option value="0">選項1</option> <option value="1">選項2</option> </select><br> <input id="submit" type="button" value="提交" name="submit"> </form>
來源http://bbs.csdn.net/topics/390905678spa