$(function () { var jumpnavcount = $(".jumpnav dt").size(); $(".htxt").each(function (index, element) { if (jumpnavcount > 0) { var obj = $(this); var a = obj.find("a"); var top = obj.offset().top; var height = obj.innerheight() top = top - height; var text = obj.find("h3").text(); obj.append("

" + text + "

"); var h4 = obj.find("h4") h4.css("left", (obj.width() - h4.width()) / 2) h4.show(); a.css("visibility", "hidden"); var cango = obj.data("cango",true); var hasgo = obj.data("hasgo", false); $(window).scroll(function () { if ($(window).scrolltop() > top + 150 && $(window).scrolltop() < top + height+100) { if (obj.data("cango")) { obj.data("cango", false); $(".htxt").eq(index-1).find("h4").stop(true, true).hide(); $(".htxt").eq(index - 1).find("a").css("visibility", "visible"); settimeout(function () { h4.animate({ left: 0, top: a.position().top, fontsize: "35px" }, 500, function () { h4.hide() a.css("visibility", "visible"); obj.data("hasgo", true); }); }, 300); } } else if ($(window).scrolltop() < top && obj.data("hasgo")) { obj.data("hasgo", false); obj.data("cango", true); h4.stop(true, false).css("left", (obj.width() - h4.width()) / 2).css("top", 0).css("font-size", "55px"); h4.show(); a.css("visibility", "hidden"); } }); } }); })