I am attached to the implementation of Twitter-Bootstrap Scrollspy in the menu, so when the user scrolls to the page section, the css class changes. This turned out to be unsatisfactory. I already use affix code from code that works great.
So, from my code below, when the user scrolls the LI element in #ScrollSpyContent , I want to change the .product_submenu_image class to .product_submenu_active .
How can i do this?
(I use jsp in java , so there might be some java code here. I tried to cut most of it.)
Thanks.
HTML:
<!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="/css/bootstrap.css"/> <link rel="stylesheet" href="/css/bootstrap-responsive.css"/> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> </head> <body> <header></header> <div class="row-fluid product_submenu"> <nav class="span10 offset1"> <ul class="productmenus"> <li><a href="#product_features"><div class="product_submenu_image"><img src="../img/product_computer.png" alt=""/> Product Features</div></a></li> <li><a href="#gettingstarted"><div class="product_submenu_image product_submenu_border"><img src="../img/product_people.png" alt=""/> Getting Started</div></a></li> <li><a href="#product_support"><div class="product_submenu_image product_submenu_border"><img src="../img/product_phone.png" alt=""/> Product Support</div></a></li> </ul> </nav> </div> <div class="container-fluid"> <nav class="row-fluid" > <ul class="span10 offset1" data-spy="scroll"> <li class="row-fluid" id="product_features"></li> <li class="row-fluid" id="gettingstarted"></li> <li class="row-fluid" id="product_support"></li> </ul> </nav> </div> <footer></footer> <script src="http://code.jquery.com/jquery-1.8.3.js"></script> <script src="/js/bootstrap.js"></script> <script> $(function() { var $spy = $('.productmenus'); $spy.scrollspy({offset: 20}); $spy.bind("activate", function(e) { </script> </body> </html>
CSS
.product_submenu_image { background: url('../img/product_tab_default.gif'); max-height: 100%; padding: 18% 0 18% 0; border: none; } .product_submenu_image.active { background: blue; }
Daveg source share