阅读背景:

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

来源:互联网 

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("读取数据出错");
  }
});$('#cTreeList7811q').tree({
  url



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: