I am looking for a tooltip popup which is appended to some links on my website.
Any idea or recommendation for something like this? Maybe jquery?
Introduction to JavaScript Tooltip. Tooltip is used for knowing the item details without opening by clicking or hovering the cursor on to it. A tooltip gives a small box with some text about the item on top of the item by clicking or moving the cursor on to it.
A tooltip is pop-up text that is displayed when a user positions the cursor over a control in MicroStrategy Web.
HTML: Use a container element (like <div>) and add the "tooltip" class to it. When the user mouse over this <div>, it will show the tooltip text. The tooltip text is placed inside an inline element (like <span>) with class="tooltiptext" .
The tooltip, also known as infotip or hint, is a common graphical user interface (GUI) element in which, when hovering over a screen element or component, a text box displays information about that element, such as a description of a button's function, what an abbreviation stands for, or the exact absolute time stamp ...
The trick is in the CSS, not the JavaScript. First create your popup in static HTML the way you want it to look when active. Then hide it and use .fadeIn()
in jQuery.
I'd try something like this:
<a href="foo.htm" class="tooltip">
Foo
<div>Tooltip content</div>
</a>
CSS:
a.tooltip {
position: relative;
}
a.tooltip > div {
display: none;
position: absolute;
bottom: 100%;
left: 50%;
margin-left: -150px;
width: 300px;
}
JavaScript:
$("a.tooltip").hover(function () {
$("> div", this).fadeIn();
},
function () {
$("> div", this).fadeOut();
});
Edit: Here's a demo: http://jsfiddle.net/gilly3/b3PjW/. I take back the part about the JavaScript not being the tricky part. Accounting for links on the edges of the screen means plenty of positioning logic. My jsfiddle does a little of it, but doesn't take into account scrollbars or vertical positioning. That may or may not be an issue for you. If it is, a good plugin should do all that for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With