JavaScript Bootstrap - Why my scrollspy is not working? bootstrap scrollspy not working,bootstrap scrollspy not working correctly,bootstrap

I've never used scrollspy in my project and I need to know how it works. I have seen the documentation from the bootstrap page, some other stackoverflow questions and youtube videos.

I have this code:

For the nav:

<!-- Start nav -->
        <nav class="navbar navbar-default navbar-fixed-top">
          <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
              <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
              </button>
              <a class="navbar-brand" target='_blank' href="#"><img id="logo" src="images/logo.png" alt="Brand"></a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
              <ul class="nav navbar-nav">
                <li class="active"><a target='_blank' href="#">Link <span class="sr-only">(current)</span></a></li>
                <li><a target='_blank' href="#">Link</a></li>
                <li class="dropdown">
                  <a target='_blank' href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
                  <ul class="dropdown-menu">
                    <li><a target='_blank' href="#">Action</a></li>
                    <li><a target='_blank' href="#">Another action</a></li>
                    <li><a target='_blank' href="#">Something else here</a></li>
                    <li role="separator" class="divider"></li>
                    <li><a target='_blank' href="#">Separated link</a></li>
                    <li role="separator" class="divider"></li>
                    <li><a target='_blank' href="#">One more separated link</a></li>
                  </ul>
                </li>
              </ul>
              <!--<form class="navbar-form navbar-left" role="search">
                <div class="form-group">
                  <input type="text" class="form-control" placeholder="Search">
                </div>
                <button type="submit" class="btn btn-default">Submit</button>
              </form>-->
              <ul class="nav navbar-nav navbar-right" id="navbar">
                <li><a target='_blank' href="#Inicio">Incio</a></li>
                <li><a target='_blank' href="#NuestrosServicios">Nuestros Servicios</a></li>
                <li><a target='_blank' href="#Portafolio">Portafolio</a></li>

                <!--<li class="dropdown">
                  <a target='_blank' href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
                  <ul class="dropdown-menu">
                    <li><a target='_blank' href="#Inicio">Action</a></li>
                    <li><a target='_blank' href="#NuestrosServicios">Another action</a></li>
                    <li><a target='_blank' href="#Portafolio">Something else here</a></li>
                    <li role="separator" class="divider"></li>
                    <li><a target='_blank' href="#">Separated link</a></li>
                  </ul>
                </li>-->
              </ul>
            </div><!-- /.navbar-collapse -->
          </div><!-- /.container-fluid -->
        </nav>
    <!-- End nav -->

For the body:

<!-- Body container -->
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-12 menu-1" id="Inicio"></div>
                <div class="col-md-12 menu-2" id="NuestrosServicios"></div>
                <div class="col-md-12 menu-3" id="Portafolio"></div>
            </div>
        </div>
    <!-- End Body container -->

The JavaScript side:

$(function() {
    $("body").scrollspy({target: "#navbar"});
});

The full example in jsbin:

Answer:1

I want to get the tags name when I click on them, I have applied a common class on each tag. Now the proplem is when ever I click on p tag or h1 it always gives the parent name. $(function(){ $...

I want to get the tags name when I click on them, I have applied a common class on each tag. Now the proplem is when ever I click on p tag or h1 it always gives the parent name. $(function(){ $...

I am trying to figure out how to use propeller.js to restrict the rotation angle of an image. As of right now, if I spin my image twice, my output would read 720. I would like to make it so the ...

I am trying to figure out how to use propeller.js to restrict the rotation angle of an image. As of right now, if I spin my image twice, my output would read 720. I would like to make it so the ...

i tried with this RegEX no solution ^([a-zA-Z]{1})([0-9]{3})$ Test Case: Valid 123d f311 12d3 99A9

i tried with this RegEX no solution ^([a-zA-Z]{1})([0-9]{3})$ Test Case: Valid 123d f311 12d3 99A9

  1. regex three letter word
  2. regex three letter month
  3. regex three letters

I have an existing Django project and am adding a new app which consists of an API (using the rest-framework) and an angular app. This app contains one Django template, which simply serves as a way ...

I have an existing Django project and am adding a new app which consists of an API (using the rest-framework) and an angular app. This app contains one Django template, which simply serves as a way ...