"JQuery Add/remove class on scroll pos bootstrap"
Bootstrap 3.0.0 Snippet by navintukral

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="wrapper"> <div class="sticker">fixed pos until 1000</div> </div> <div class="marker">< 1000</div>
body { font-family: 'Helvetica', sans; } div.wrapper { margin: 260px auto; width:600px; background:#efe; height: 3900px; } div.sticker { padding: 20px; margin: 20px 0; background: #ece; width: 190px; } .stick { position:fixed; top:0px; } .marker { position: absolute; top: 1000px; right: 100px; font-size: 2em; }
$(document).ready(function() { var s = $(".sticker"); var pos = s.position(); $(window).scroll(function() { var windowpos = $(window).scrollTop(); if (windowpos >= pos.top & windowpos <=1000) { s.addClass("stick"); } else { s.removeClass("stick"); } }); });

Related: See More


Questions / Comments: