Last active
October 26, 2015 15:25
-
-
Save connordavison/9cb59d7a668bcec7a149 to your computer and use it in GitHub Desktop.
Make an element popup over another.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.fn.popup = function (tooltip) { | |
| var targets = $(this); | |
| targets.click(function () { | |
| var target = $(this); | |
| var desired = { | |
| left: target.position().left + target.width() / 2, | |
| top: target.position().top - tooltip.height() | |
| }; | |
| var current = tooltip.position(); | |
| if (current.left == desired.left && current.top == desired.top) { | |
| tooltip.hide(); | |
| } else { | |
| tooltip.show(); | |
| tooltip.offset(desired); | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment