2014-10-27 4 views
0

Так что в предыдущем вопросе я не мог заставить JQuery Mousemove работать над этими всплывающими подсказками для этих div в рамках 14-ти столбцовой сетки 960, которые у меня есть. Теперь они работают в некоторой степени. Они будут следовать за моей мышью, как 7-й или 8-й столбец (ширина). Если вы прокрутите весь путь вправо, где другие divs - всплывающая подсказка, останавливается в определенной точке. Не уверен, что мешает его от следующего за ним весь путь .... Вот ссылка на него на JSFiddle: http://jsfiddle.net/penrysh/eoL1qqf9/JQuery Tooltip mousemove событие не следующая мышь для всех Divs

Вот это 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 

ответ

1

изменить это:

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

к настоящему времени:

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