$(function() { // 时间格式化,var date_string = new Date().Format('yyyy-mm-dd hh:ii:ss'); Date.prototype.Format = function(fmt) { //author: meizz var o = { "m+": this.getMonth() + 1, //月份 "d+": this.getDate(), //日 "h+": this.getHours(), //小时 "i+": this.getMinutes(), //分 "s+": this.getSeconds(), //秒 "q+": Math.floor((this.getMonth() + 3) / 3), //季度 "S": this.getMilliseconds() //毫秒 }; if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt; } // 让IE8支持trim方法 if (!String.prototype.trim) { String.prototype.trim = function() { return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); }; } // 从表单获取json对象数据用于ajax提交 jQuery.prototype.serializeObject = function() { var obj = new Object(); $.each(this.serializeArray(), function(index, param) { if (!(param.name in obj)) { var rgexp = /\[\]/; if (rgexp.test(param.name)) { var key = param.name.replace(rgexp, ''); if (!obj.hasOwnProperty(key)) { obj[key] = []; } obj[key].push(param.value); } else { obj[param.name] = param.value; } } }); return obj; }; // 让IE8支持placeholder方法 var supportPlaceholder = 'placeholder' in document.createElement('input'); if (!supportPlaceholder) { jQuery('[placeholder]').focus(function() { var input = jQuery(this); if (input.val() == input.attr('placeholder')) { input.val(''); input.removeClass('placeholder'); } }).blur(function() { var input = jQuery(this); if (input.val() == '' || input.val() == input.attr('placeholder')) { input.addClass('placeholder'); input.val(input.attr('placeholder')); } }).blur().parents('form').submit(function() { jQuery(this).find('[placeholder]').each(function() { var input = jQuery(this); if (input.val() == input.attr('placeholder')) { input.val(''); } }) }); } });