<form onsubmit="return concatFormDataToUri(this,hh)"> <input name="name" text="233223"> <input name="name" text="233223"> <select name="232323"><option checked="true">4444444</option><option >2332232323</option></select> <input type="submit" value="提交"> </form>
var concatFormDataToUri = function(_this,_function){ $_inputs = $(_this).find(":input"); var _uri = ""; $.each($_inputs,function(){ //如果是select对象 if(this instanceof HTMLSelectElement){ _uri +="&"+this.name+"="+$(this).find(":checked").val(); }else if(this instanceof HTMLInputElement && this.type!="submit" && this.type!="reset"){ //input对象 _uri +="&"+this.name+"="+this.value; } _uri = _uri.substring(1,_uri.length) }) this.formDataUrl=_uri; _function(); return false; } function hh(){ alert(formDataUrl); }
结果: