0

I would like to make a Bootstrap navbar using the Scrollspy plugin. When I try to use it, the last <li> tag always remains active but does not let the the other <li> elements go active. If you would like my code: http://pastebin.com/raw.php?i=QL99wh2C and here's an image of what I am talking about: https://i.stack.imgur.com/CYzg9.png

Bass Jobsen
  • 48,736
  • 16
  • 143
  • 224
Darkmag98
  • 11
  • 2

1 Answers1

0

From your source:

  1. add <!DOCTYPE html> to the top of your document
  2. the data-target in your body tag should contain a css selector. In your case #navbar or .navbar instead of navabar. b.e. data-target="#navbar"
  3. see this question: Twitter Bootstrap scrollspy always selecting last element so use: $('body').scrollspy();
    1. gives none selected / active on page load; add class="active" to the first li in your code. Or $('.nav li:first').addClass('active'); to the bottom of your document.
Community
  • 1
  • 1
Bass Jobsen
  • 48,736
  • 16
  • 143
  • 224