The Jquery tooltip does not correctly track the mouse movement across all div elements

Previously, I encountered an issue with the Jquery Mousemove feature not working properly on tooltips within divs in a 14 column 960 grid system. Now, although they work to some extent, they only follow my mouse up to the 7th or 8th column width. When scrolling all the way to the right where additional divs are located, the tooltip stops at a certain point and doesn't fully follow. I am unsure of what is causing this limitation. You can view the code on JSFiddle: http://jsfiddle.net/penrysh/eoL1qqf9/

The JQuery script used is as follows:

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

if( $(this).attr('data-tip-type') == 'text' ){
$('#tooltip_container').html( $(this).attr('data-tip-source') );        
} 

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

$('#tooltip_container').html(newHTML);
}
}).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'); 
}else{
$('#tooltip_container').css('left',(e.pageX-20)+'px'); 
}

$('#tooltip_container').css('top',(e.pageY+20)+'px');

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

}); 

Answer №1

modify the following:

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

to this:

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can Ajax be used to execute PHP code without requiring a page refresh and to establish variables

I need help with a small PHP script that involves buttons and AJAX. The script does not contain a form, but when I click on a button, I want to execute a PHP script based on the id using AJAX. Here are the buttons: <button onclick="deleteTask()" class ...

CSS: Turn off the custom styling for radio buttons

My dilemma lies in the custom radio button I've created using CSS. The issue is that while I can select the radio button, I cannot deselect it. Here is a snippet of the CSS code I used to create the custom radio button: input[type="radio"]:checked:be ...

Resizing cell height in an HTML table is not supported by Angular 5

In my angular application, I've implemented a component that represents a basic HTML table. However, I'm facing an issue with reducing the height of cells within the table. It seems like my CSS styling is not affecting the display as desired. He ...

Trouble in connecting local CSS stylesheet

I am facing an issue with adding my .css file to my project. Even though I have tried various methods, the styles are not being applied properly. When I directly embed the style code in HTML, it seems to work fine. This leads me to believe that the proble ...

JavaScript post method for JSON data: no input or output values

I am currently developing a page that extracts data from an HTML table consisting of two columns and an index of a form, and then converts it into a JSON string. The intention is to pass this data into PHP for further processing, perform calculations on th ...

Unforeseen behavior of $.Ajax within a loop

While executing my code <div id="#1gr1">Kun</div> for(var i=1;i<=10;i++){ $.ajax({ type: "POST", url: "get_url.php", async: false, data: {a: 'hi'} }).d ...

Using Jquery to enhance navigation tabs with pointers

I am facing an issue where the class .hover and .over are added to the entire list whenever I mouseover any list item. I understand that this is happening due to my jQuery code, but I would like to find a way for jQuery to only add the class to the specifi ...

Having trouble adding flexslider before a div element with jQuery

Hey there! I recently got flexslider from woothemes.com. The page structure I'm working with looks something like this: <div class="parentdiv anotherdiv"> <div class="child-div1">some buttons here</div> <div class="child-div2"& ...

Why is adding a div to Facebook posts using JQuery failing due to dynamic loading?

I have been experimenting with the mouseover feature to enhance a Facebook group by adding additional content. Upon testing the DIV class, I realized that after the initial 10 or so instances of DIVs with the class storyInnerWrapper, the text stopped being ...

Using jQuery each, the output is an undefined Object or HTMLElement

Using jQuery's each/getJSON to iterate through a data.json file, collect and format the data, and display it on the page within the #output div. The functionality is working correctly, except for the unexpected addition of [object HTMLElement] that a ...

Tips for positioning elements on smaller screens in tailwindcss

Here is the code I'm currently working with. However, on mobile devices, the Connect button is positioned on the left side as shown in this image: https://i.sstatic.net/dd4Wg.png. My goal is to relocate the connect button to the right side on mobile ...

Adding a div by its id with the help of jQuery

I am attempting to implement infinite scroll functionality for a list of products. My goal is to add a div with the id "products" when the user reaches the bottom of the page. However, my current approach is not working as expected. $(window).scroll(func ...

How can I implement a single Ajax call to load content from various pages and display it

This code facilitates an ajax call to dynamically change the content of a div in the main page without requiring a full page reload: function ajaxcall() { $.ajax({ type: "POST", url: "/create.php", success: function( returnedDa ...

Positioning an immovable element beneath a fixed element that can vary in height

I am working on a webpage that features a fixed menu at the top-left corner, followed by the main content. My goal is to ensure that the content appears below the menu, but since I do not know the exact height of the menu in advance (as it can vary based o ...

Slowly introduce a sequence of divs, then smoothly fade out the div that came before

After successfully using jQuery to create a smooth fade-in effect for a series of divs, I am now looking to incorporate a fade-out transition for the previous div. My plan is to include a fade out function as a callback within the existing fade in function ...

"Unlocking the Power of mediaElementjs: Easy Steps to Accessing the Player Instance

I'm facing a small issue with the MediaElement.js player. To access the player instance, I usually use the following code (which works in HTML5 compatible browsers): // Retrieve player this.playerId = $('div#shotlist-player video').att ...

What is the best way to align text in the middle of a card using bootstrap?

I crafted a code to display cards using Bootstrap 4. My goal now is to center all the text inside the card, but I'm facing challenges in achieving this. I attempted to apply "text-center" to the entire section. I also tried using "d-flex" and justify ...

Jquery click event only firing once

My challenge is drawing lines between two points, although I've managed to do it once. The issue arises when I try to repeat the process; nothing happens on the second click of a circle. Please note that this functionality only works in modern brow ...

Modify the cost directly on the search results page using PHP

I am new to PHP and SQL and I have a question regarding updating the price on a search result page in PHP. I want to include an input field and a submit button that will allow me to update the price of books displayed in the search results. After submittin ...

Load data into Handsontable using AJAX when the site is freshly loaded

Could you please clarify the reason behind the functionality of this code: $(document).ready(function () { var container = document.getElementById('example'); function fetchData() { var dataResult = null; $.ajax({ ...