【问题标题】:Jquery Tooltip mousemove event not following mouse to all DivsJquery Tooltip mousemove 事件不跟随鼠标到所有 Div
【发布时间】:2014-10-27 02:10:50
【问题描述】:

所以在上一个问题中,我无法让 Jquery Mousemove 功能在我拥有的 14 列 960 网格系统中为这些 div 处理这些工具提示。现在他们在某种程度上起作用了。他们只会跟随我的鼠标喜欢第 7 或第 8 列(宽度)。如果您一直滚动到其他 div 所在的右侧,则工具提示会在某个点停止。不知道是什么阻止它一直跟随它......这是JSFiddle上的链接: http://jsfiddle.net/penrysh/eoL1qqf9/

这里是 jquery:

$(document).ready(function(){
$('.tooltip').mouseover(function(e){

if( $(this).attr('data-tip-type') == 'text' ){
$('#tooltip_container').html( $(this).attr('data-tip-source') );        
} // this section grabs and shows the plain text tool-tip  typles

if( $(this).attr('data-tip-type') == 'html' ){
var elementToGet = '#'+ $(this).attr('data-tip-source');
var newHTML = $(elementToGet).html();

$('#tooltip_container').html(newHTML);
} // this section grabs and shows the tool-tips that are HTML and can be formatted and are in divs at bottom on index page
}).mousemove(function(e){

var toolTipWidth = $('#tooltip_container').outerWidth();
var toolTipHeight = $('#tooltip_container').outerHeight();

var pageWidth = $('body').width();
if ( e.pageX > pageWidth/2) {
$('#tooltip_container').css('left',(e,pageX-toolTipWidth+20)+'px'); // takes tooltip width and subtract from pageX position                                      so it will always be offset from the cursor based on the tooltip itself
}else{
$('#tooltip_container').css('left',(e.pageX-20)+'px'); // Determines where courser is and subtracts 20pxs from it
}

$('#tooltip_container').css('top',(e.pageY+20)+'px'); // Determines where courser is and subtracts 20pxs from it

}).mouseout(function(e){
});

}); // end ready

【问题讨论】:

    标签: jquery html css mousemove 960.gs


    【解决方案1】:

    改变这个:

    $('#tooltip_container').css('left',(e,pageX-toolTipWidth+20)+'px');
    

    到这里:

    $('#tooltip_container').css('left',(e.pageX-toolTipWidth+20)+'px');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-08
      • 2019-03-17
      • 1970-01-01
      • 1970-01-01
      • 2015-11-10
      • 1970-01-01
      • 1970-01-01
      • 2011-03-24
      相关资源
      最近更新 更多