each处理一维数组二维数组和JS改变屏幕事件

改变屏幕大小事件
window.onresize=function(){
            var w=$(window).width();
            if((w<1189)){
                $('.one').hide();
            }
        }

each处理一维数组
$.each(arr,function(i,val)){
alert(i);alert(val)
}
each处理二维数组
$.each(arr2,function(i,item){
    alert(i)输出二维数组有几个数组元素
    alert(item) 将输出每一个数组
})


 
var scrollFunc = function(e) {
var direct = 0;
e = e || window.event;
if (e.wheelDelta) {  //判断浏览器IE,谷歌滑轮事件
if(e.wheelDelta > 0) { //当滑轮向上滚动时
alert("滑轮向上滚动");
}
if(e.wheelDelta > 0) { //当滑轮向上滚动时
alert("滑轮向上滚动");
}
if(e.wheelDelta < 0) { //当滑轮向下滚动时
alert("滑轮向下滚动");
}
} else if (e.detail) {  //Firefox滑轮事件
if(e.detail>0) { //当滑轮向上滚动时
alert("滑轮向上滚动");
}
if (e.detail< 0) {
//当滑轮向下滚动时
alert("滑轮向下滚动");
}
}
ScrollText(direct);
}
//给页面绑定滑轮滚动事件
if(document.addEventListener) {
document.addEventListener('DOMMouseScroll',scrollFunc, false);
}
//滚动滑轮触发scrollFunc方法
window.onmousewheel =document.onmousewheel = scrollFunc;
posted @ 2017-05-24 14:51  lxn*  阅读(290)  评论(0编辑  收藏  举报