js添加移入移出事件

function addhtml(data) {
    var num = 5;
    // var arr= new Array(1,2,3,4,5,6,7,8,9,10,11,12);
    // console.log(data);
    var Math_ceil = Math.ceil(data.length/num);
    // var Math_ceil = Math.ceil(arr.length/num);
    var index = 0;
    for(var i=1;i<=Math_ceil;i++){
        index = (i-1)*5;
        $('#div').append('<div id="div'+i+'" class="div_1"></div>');
        var s = data.slice(index,index+num);
        // console.log(s);
        for(var j in s){
            $('#div'+i).append(`<div class="img_div" id="div_img${s[j]['aid']}" oncontextmenu="img_divs(${s[j]['aid']})"><div class="img_div2" onclick="${s[j]['fun']}()"><div><img src="${s[j]['actionimg']}"></div><div class="title_text">${s[j]['actionname']}</div><div></div>`);
        }
        console.log($('.img_div2'));
        $('.img_div2').mouseover(function(){
            var aa = $(this);
            change(aa);
        });
        $('.img_div2').mouseout(function(){
            out($(this));
        })
    }
}

function change(obj){
    $(obj).css('background-image','url(img/1.png)');
}

function out(obj){
    $(obj).css('background-image','');
}

 

posted on 2018-12-10 22:35  lxc_bky  阅读(1010)  评论(0编辑  收藏  举报

导航