0

I'm trying to trigger the dropdown button from another button and can't seem to get it to work. jsfiddle

<button type="button" class="btn btn-primary" id="btnFilter">Action</button>
<button type="button" id="btntest" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false" style="display:none;">Action <span class="caret"></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>

JS

$(function(){
    $('#btnFilter').on('click', function(){
       $("#btntest").trigger('click');
    });
});
1
  • in my case it needs to be display none :( Commented Jan 6, 2015 at 0:12

1 Answer 1

1

Add stopPropagation to your button click.

http://jsfiddle.net/cv19ou74/1/

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.