一、jq上傳進度html
var xhrOnProgress = function (fun) { xhrOnProgress.onprogress = fun; return function () { var xhr = $.ajaxSettings.xhr(); if (typeof xhrOnProgress.onprogress !== 'function') return xhr; if (xhrOnProgress.onprogress && xhr.upload) { xhr.upload.onprogress = xhrOnProgress.onprogress; } return xhr; } }; $.ajax({ type: "POST", url: "http://180.97.83.70:30990/wxapp/addUserPhotoAlbumCmd/", data: formData, processData: false, //必須false纔會自動加上正確的Content-Type contentType: false, xhr: xhrOnProgress(function (e) { var percent = 100 * e.loaded / e.total;//計算百分比 $("#upinfo").html(Math.floor(percent) + '%'); }), success: function (res) { }, error: function (e) { } }); });
二、json排序web
var testList = [ {n: "1"}, {n: "2"}, {n: "3"}, {n: "4"}, {n: "5"} ]; function sortList(a, b) { return b.n - a.n } testList.sort(sortList) console.log(testList)
三、獲取7天時間日期ajax
var dates=[]; var datestr; function getDate() { var myDate = new Date(); myDate.setDate(myDate.getDate()-6); //前7天 for (var i = 0; i < 7; i++) { datestr=Number(myDate.getMonth()) + 1 + "-" + myDate.getDate(); dates.push(datestr); myDate.setTime(myDate.getTime() + 1000*60*60*24); //console.log(datestr); } //$scope.proSevDay=dates;//日期 //console.log(dates); }
四、判斷頁面滾動到底部json
$(document).ready(function () { $(window).scroll(function () { if ($(document).scrollTop() >= $(document).height() - $(window).height()) { console.log("到底了") } }); });
五、相同key值加入新數組windows
var b = {}; result.forEach(function (obj) { var array = b[obj['time']] || []; array.push(obj); b[obj['time']] = array; }); console.log(b);
六、meta數組
<!-- 啓用360瀏覽器的極速模式(webkit) --> <meta name="renderer" content="webkit"> <!-- 避免IE使用兼容模式 --> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- 針對手持設備優化,主要是針對一些老的不識別viewport的瀏覽器,好比黑莓 --> <meta name="HandheldFriendly" content="true"> <!-- 微軟的老式瀏覽器 --> <!-- 微軟的老式瀏覽器 --> <meta name="MobileOptimized" content="320"> <!-- uc強制豎屏 --> <meta name="screen-orientation" content="portrait"> <!-- QQ強制豎屏 --> <meta name="x5-orientation" content="portrait"> <!-- windows phone 點擊無高光 --> <meta name="msapplication-tap-highlight" content="no">