I'm trying to make use of this answer's tooltip code, but I've encountered a few problems. The tooltip doesn't let me type text in a <input>
element and also makes jumps when I scroll far down the table, like this:
while it's supposed to follow the cursor. I made this fiddle: https://jsfiddle.net/nuvgef12/ and here's the code:
css:
.tooltip {
display: inline-block;
position: fixed;
padding: .5em 1em;
background-color: red;
}
html:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<h4 id="log">pageX: -, pageY: -</h4>
<div class="tooltip">I'm a tooltip!</div>
<input type="text" placeholder="Enter something">
<table class='items'>
<thead>
<tr class="table-header">
<th>Id</th>
<th>Icon</th>
<th>Name</th>
</tr>
</thead>
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>12</td>
<td>12</td>
<td>12</td>
</tr>
...
js:
$( document ).on( "mousemove", function( event ) {
$( "#log" ).text( "pageX: " + event.pageX + ", pageY: " + event.pageY );
$( ".tooltip" ).css({
"left" : event.pageX,
"top" : event.pageY
});
});
EDIT:
The given solutions help with letting putting the text inside input, but there still exists the problem with jumping. It happens after a scroll down the table - the tooltip briefly disappears and then reappears much off to down and to the side.