1
I’m trying to recreate this tooltip http://jsfiddle.net/HJf8q/ with jQuery.
$(document).ready(function(){
$(".tooltip").mousemove(function(event) {
$(".text").style.top = (event.pageY + 20) + "px";
$(".text").style.left = (event.pageX + 20) + "px";
});
});
.tooltip {
position: relative;
}
.tooltip span {
display:none;
}
.tooltip:hover span {
display:block;
position:fixed;
overflow:hidden;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="tooltip">
<span class="text">Texto</span>
<p>Passe o mouse aqui.</p>
</div>
However, Text does not follow mouse movement. Could someone tell me how to do this?
jQuery is returning all found elements, so it is an object, change
$(".text").style
for$(".text")[0].style
, if you have more than one element you will have to traverse this object.– NoobSaibot
See working in jsfiddle.net
– NoobSaibot
That’s right! Thank you very much!
– Paulo Dos Santos
@Noobsaibot Put as answer.
– Paulo Dos Santos