Easyui-tree 文本过长,鼠标悬停显示完整的信息

来源:互联网 发布:财新数据 编辑:程序博客网 时间:2024/05/22 08:02

js代码:

$('#cTreeList7811q').tree({  url:strUrl,  // 数据来源地址  method:'post',  animate:true,  onLoadSuccess:function(node,data){      $('#cTreeList7811q').on('mouseenter','span.tree-title',function(){//      console.log($(this).text());        var curZindex=$(this).parents('.window').css('z-index')+100;        var itemTxt=$(this).text();        var itemWidth=$(this).width()+4; // 4像素是padding的左右值各2        var itemLeft=$(this).position().left; // node.text文本相对于父元素偏移多少        var cTreeWidth=$('#cTreeList7811q').width();        if((itemWidth+itemLeft)>cTreeWidth){          if($('body').find('.tip').length!=0){            $('body').find('.tip').remove();        }else{          var html='<div class="tip">'+itemTxt+'</div>';            $('body').append(html);            $('.tip').css({'top':$(this).offset().top+15,'left':$(this).offset().left,'z-index':curZindex});        }                    }      });            $('#cTreeList7811q').on('mouseleave','span.tree-title',function(){        if($('body').find('.tip').length!=0){        $('body').find('.tip').remove();          }      });  },  onLoadError:function(){    showError("读取数据出错");  }});
鼠标悬停显示完整Tip是根据弹出窗口的宽度来计算

阅读全文
0 0
原创粉丝点击