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是根据弹出窗口的宽度来计算