You don't even need javascript, but the problem in your example is that you did not load jQuery. You can do this from the top left navigation in the JSFiddle.
Here is an example in JSFiddle using only CSS: JSFiddle
HTML:
<div class="wrapper"> <span>Visible Content (Hover Me)</span> <span class="hidden-content">Hidden Content (Visible when hovered)</span> </div>
CSS
.wrapper { position: relative; } .hidden-content { display: none; position: absolute; } .wrapper:hover .hidden-content { display: block; }
JS:
$(function() { $(".wrapper").hover(function (e) { var parentOffset = $(this).parent().offset(); var relX = e.pageX - parentOffset.left; $(".hidden-content").css("left", relX); }); });
source share