/********************************** * * 发送短信的JS * **********************************/ (function($) { $.fn.serializeObject = function() { var o = {}; var a = this.serializeArray(); $.each(a, function() { if (o[this.name]) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(this.value || ‘‘); } else { o[this.name] = this.value || ‘‘; } }); return o; }; $.fn.formSubmit = function(opts) { var defaults = { } var opts = $.extend(defaults, opts); var $btn=$(this).find("input[type=‘button‘]"); var form=$(this); $btn.bind("click",function(){ var json = form.serializeObject(); alert(JSON.stringify(json)); }); } })(jQuery);
代码依赖JQuery,效果如:
时间: 2024-09-28 01:10:33