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
Asked
Active
Viewed 519 times
0

Bass Jobsen
- 48,736
- 16
- 143
- 224

Darkmag98
- 11
- 2
1 Answers
0
From your source:
- add
<!DOCTYPE html>
to the top of your document - 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"
- see this question: Twitter Bootstrap scrollspy always selecting last element so use:
$('body').scrollspy();
- 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.
- gives none selected / active on page load; add class="active" to the first li in your code. Or

Community
- 1
- 1

Bass Jobsen
- 48,736
- 16
- 143
- 224