jquery 應用實踐

頁面若是報錯  text不是一個方法 ,說明不是 jquery 對象   須要 將他變成jquery對象 在用jquery 的 方法進行操做
$("#view thead th").each(function (i) {

    console.log($($(this).get(0)).text());

})

 

jquery 上傳文件和表單  的 時候,, 使用  FormData ,,  springmvc  只能 返回json 數據 不能夠用mode 返回頁面html

var form = new FormData($("#form-excel-batch")[0]);

文件上傳 推薦     jquery-fileinputjquery

jquery 全選全不選web

https://www.helloweba.com/view-blog-254.htmlspring

判斷輸入框是否 選中json

if($('#checkbox-id').is(':checked')) {
    // do something
}mvc

 

jquery給文本框綁定按鍵事件並延時觸發,只觸發一次!

        jQuery(function ($) {
            var delay = (function () {
                var timer = 0;
                return function (callback, time) {
                    clearTimeout(timer);
                    timer = setTimeout(callback, time);
                };
            })();

            $('#id').keyup(function () {
                delay(function () {
                    console.log('test');
                }, 1000);
            });
        })

 

jquery 清空from 表單this

      ($("選擇器"))[0].reset();spa

 

jquery 將時間戳轉日期方法    excel

function getMyDate(str){
    var oDate = new Date(str),
        oYear = oDate.getFullYear(),
        oMonth = oDate.getMonth()+1,
        oDay = oDate.getDate(),
        oHour = oDate.getHours(),
        oMin = oDate.getMinutes(),
        oSen = oDate.getSeconds(),
        oTime = oYear +'-'+ getzf(oMonth) +'-'+ getzf(oDay) +' '+ getzf(oHour) +':'+ getzf(oMin) +':'+getzf(oSen);//最後拼接時間
    return oTime;
};
//補0操做
function getzf(num){
    if(parseInt(num) < 10){
        num = '0'+num;
    }
    return num;
}
相關文章
相關標籤/搜索