Home >Web Front-end >JS Tutorial >Navigation fixed effect implemented by jquery_jquery

Navigation fixed effect implemented by jquery_jquery

WBOY
WBOYOriginal
2016-05-16 16:51:081107browse

Navigation fixed effect implemented by jquery

Copy code The code is as follows:

1.jquery code, .nav is the navigation class
$(function(){
$(window).scroll(function() {
if($(window).scrollTop()>=250){
$(".nav" ).addClass("fixedNav");
}else{
$(".nav").removeClass("fixedNav");
}
});
});

2.CSS code
.fixedNav{
position:fixed;
top:0px;
left:0px;
width:100%;
z-index:100000 ;
_position:absolute;
_top:expression(eval(document.documentElement.scrollTop));
}

3.HTML code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn