Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Chris Turner
9,710 PointsFramework Basics Challenge Task: Data Attribute Toggle for Nav
I'm stuck on the challenge task: Finally, add the data attribute that toggles the nav once the menu icon is clicked.
This is what I have in the text editor:
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="navbar.collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
I watched the preceding video thoroughly and I've compared the files against the challenge code and I can't find what I'm missing. Help!
4 Answers
Chris Turner
9,710 PointsFigured it out. The data-target should be:
.navbar-collapse
Not navbar.collapse.
James Barnett
39,199 Points> I watched the preceding video thoroughly
In this case, this exact syntax is covered starting at time index 8:40
Jose Guerrero
4,933 PointsAt least you were somewhere in the ball park. I was trying to keep from peeking at the vids and my own follow-along code by using the getbootstrap.com components reference page. It ended up just confusing me with the: data-target="#bs-example-navbar-collapse-1"
Miguel de Luis Espinosa
41,279 PointsI find it odd not to use an id attribute. I think that would be more clear.
James Barnett
39,199 PointsCSS frameworks don't use IDs because they are reuseable design elements that can be use more than once on a page.
CD Kilpatrick
1,268 PointsJames Barnett That makes sense, but then why does bootstrap's components docs show the collapse with an id? (As mentioned above, id="bs-example-navbar-collapse-1")