1

As you can see I created a btn-group

<div class="row">
    <div class="col-lg-12">
         <div class="btn-group inline">
              <a href="#" class="btn btn-success" >Offline</a>

              <a class="btn btn-info" id="print_map_btn">Print</a>
              <a href="#" class="btn btn-info dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>
              <ul class="dropdown-menu pull-right" id="print_options">
                <li data-option="complete_map"><a href="#">Complete</a></li>
                <li data-option="map_sector"><a href="#">Act</a></li>
              </ul>
         </div>
    </div>
</div>

When you click on the Arrow on the right, the dropdown opens

I would like to achieve that when someone clicks on the Print button on the left, the dropdown opens.

I tried to achieve it like this:

var print_btn = $('#print_map_btn');

print_btn.click(function(){
    $('.btn-group').addClass('open');
});

But it won't work: http://jsfiddle.net/52VtD/13893/

How can I fix it? Thanks

2
  • 5
    You don't need the added jQuery script. Just add data-toggle="dropdown" to the trigger. Like this jsfiddle.net/52VtD/13895 Commented Jan 14, 2016 at 22:16
  • @ChrisYongchu great It works! Could you please write an answer? Commented Jan 14, 2016 at 22:20

1 Answer 1

2

To accomplish what you're trying to do, just simply add the data-toggle="dropdown" attribute to the link or button you want to toggle the dropdown menu.

I've updated your fiddle for you to review. http://jsfiddle.net/52VtD/13895/

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.