js实现鼠标移入显示弹框,移出弹框消失

  • Post author:
  • Post category:其他



```javascript
layui.use('layer',function(){
    var layer = layui.layer;
    $(function(){
         var tips 
        $('.project').on({                    
            mouseenter:function(){
            var that = this;
            var pj
            this.style.color = 'blue'
            pj = $(this).html()
            datap = {data:{"pj":pj}}
            $.ajax({
                url: "/manage/peopleviewajax",
                type:"get",
                data: datap.data,
                data_type: 'json',
                success:function(res){
                        res = JSON.parse(res)
                        console.log('****',res.data)
                        data = res.data
                        var h = ''
                        for(var i in data){
                            console.log(i)
                            h += "<span style='color:#000;'>"+i+":"+data[i]+"</span><br>"
                        }
                        tips = layer.tips(
                            h,
                            that,
                            {tips:[3,'#fff'],time:0,area: 'auto',maxWidth:1000})
                }
            });
        },
            mouseleave:function(){
              this.style.color='#666'
              layer.close(tips);
            }
        });
    });
})

其中,弹框是借助layui中tips模块实现,弹框内容使用ajax动态获取后台数据



版权声明:本文为weixin_45514627原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。