determine the element top
Hi,
I want to determine the top of my nav menu so when the user scrolls up and the nav reaches top position 40 then I want to change its position to fixed. I tried below code but didn't work.
kindly help..
- <script type="text/javascript">
- $(document).ready(function()
- {
- $(window).scroll(function(){
- // if($(window).scrollTop() > 80)
- if($("#nav").position().top <= 40)
- {
- $("#logoheader").hide( "drop", { direction: "down" }, "slow" );
- $("#imageSmallLogo").show( "drop", { direction: "down" }, "slow" );
- $("#nav").css("position", "fixed");
- }
- else
- {
- $("#logoheader").show( "drop", { direction: "up" }, "slow" );
- $("#imageSmallLogo").hide( "drop", { direction: "up" }, "slow" );
- }
- });
- });
- </script>