笔记

js循环获取多选择的集合

var checked = []

$("input[name=user_id]:checkbox:checked").each(function(){

  checked.push($(this).val())

})
View Code

input=>type=file如果要支持多文件上传选定

<input  type="file" name="file[]" multiple/>
View Code

表格中,直接编辑,失去焦点触发事件

<td>
    <input type="text" onblur="edt(this)"/>
</td>
View Code

当input的值发生改变的时候触发的方法

<input oninput="xxx()"/>
View Code

 

jquery定时器,每个多少时间执行一次

$(function () {
    setInterval(aa,100);
    function aa(){}
    //或者直接
    setInterval(function(){},100);
})

//以下方法只执行一次,即使在使用history.back()回到这个页面也是只会被执行一次
setTimeout(aa(),100)
function aa(){}
View Code

 jquery处理未来元素(即动态加载的元素)处理方法

$("body").delegate("元素","click",function(){
    // 执行的方法,此处的$(this)指的是当前点击的对象
    $(this).xxx();
})
View Code

a链接在点击之前先判断

<a href="xx" onclick="return confirm('确定删除?')">删除</a>
View Code

css超过宽度隐藏

overflow:hidden;white-space:nowrap;text-overflow:ellipsis
View Code

 

原文地址:https://www.cnblogs.com/fpcing/p/8986464.html