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;
}
相关文章
相关标签/搜索