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

CSS Framework Basics Prototyping with Bootstrap Build a Fixed Navbar

Can't work out how to add data attribute for Bootstrap

'Finally, add the data attribute that toggles the nav once the menu icon is clicked.'

<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>
        <a class="navbar-brand text-muted" href="#">Ribbit</a>
        <div class="collapse navbar-collapse">
          <ul class="nav navbar-nav navbar-right">
            <li class="active"><a href="#">Home</a></li>
            <li><a href="#">About Ribbit</a></li>
            <li><a href="#">Treehouse</a></li>
          </ul>
        </div>
      </div>
    </div>

Watched video 3 times. Still can't work out where it goes.

2 Answers

Siva Ganesh
Siva Ganesh
23,733 Points

Add data-target=".navbar-collapse" to the button.

Greg Jones
Greg Jones
7,451 Points

data-target is looking for a css selector, but what you are handing is structured more like a tag name.

Such as <div id="foo"/> has a css selector of #foo

I'm sure fixing up the data-target to be written like it was selecting a class would do the trick :)