Skip to content

Instantly share code, notes, and snippets.

@alanerzhao
Created January 23, 2014 08:55
Show Gist options
  • Save alanerzhao/8575211 to your computer and use it in GitHub Desktop.
Save alanerzhao/8575211 to your computer and use it in GitHub Desktop.
function upDownShow (currObj,showObj) {
var top = currObj.offset().top,
height = showObj.height(),
curHeight =currObj.height();
winTop = $(window).scrollTop();
if(top-winTop < height) {
showObj.css({"top":curHeight}).show();
} else {
showObj.css({"top":-height})
}
}
$(function () {
$(".click").hover(function () {
upDownShow($(this),$(".show"))
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment