jquery获取表单中的数据

           <form>

                <input name="username" type="text"/>

                <input name="password" type="password"/>

                <input id="submitButton" type="button" value="submit">

            </form>

             $("#submitButton").click(function(){
                    var data = {};
	            var t = $('form').serializeArray();
	            $.each(t, function() {
	                 data [this.name] = this.value;
	            });
	            alert(JSON.stringify(data));
            });
posted @ 2019-12-01 08:52  经典鸡翅  阅读(711)  评论(0编辑  收藏  举报