2

When click on bootstrap button a list should be opened, but it doesn't respond on the click.

<div class="btn-group" dropdown>
  <button type="button" class="btn btn-info">test</button>
  <button type="button" class="btn btn-info dropdown-toggle">
    <span class="caret"></span>
    <span class="sr-only">Split button!</span>
  </button>

  <ul class="dropdown-menu" role="menu">
    <li><a href="#">Action</a>
    </li>
    <li><a href="#">Another action</a>
    </li>
    <li><a href="#">Something else here</a>
    </li>
    <li class="divider"></li>
    <li><a href="#">Separated link</a>
    </li>
  </ul>
</div>

code:
http://jsfiddle.net/Fanadka/r0sfvrcz/

Any idea?

1
  • in addition to @adeneo solution, we should change the order of the files as below: <!-- jQuery --> <script src='bower_components/jquery/dist/jquery.min.js'></script> <script src='bower_components/jquery/dist/jquery.js'></script> <!-- bootstrap CSS--> <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css"> <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script> instead of having bootstrap before stackoverflow.com/questions/22658015/… Commented Dec 12, 2015 at 20:37

1 Answer 1

1

Firstly, you have to include jQuery in your fiddle.

Secondly, you're missing the connection between the button and the dropdown, you'll should add an ID and some aria tags, like this

<div class="btn-group dropdown">
    <button type="button" class="btn btn-info">test</button>
    <button type="button" class="btn btn-info dropdown-toggle" id="mydp" data-toggle="dropdown" aria-haspopup="true" >
        <span class="caret"></span>
        <span class="sr-only">Split button!</span>
    </button>
    <ul class="dropdown-menu" role="menu" aria-labelledby="mydp">
        <li><a href="#">Action</a>
        </li>
        <li><a href="#">Another action</a>
        </li>
        <li><a href="#">Something else here</a>
        </li>
        <li class="divider"></li>
        <li><a href="#">Separated link</a>
        </li>
    </ul>
</div>

FIDDLE

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.