Bootstrap Dropdown menu selected item not loading -


linked bootstrap.min.css, bootstrap-theme.min.css, jquery.min.js", bootstrap.js,dropdown.js

http://jsfiddle.net/id10922606/54edxsmv/1/

<script type="text/javascript"> $(document).ready(function(){ $('.dropdown-toggle').dropdown() }); </script>  <div class="btn-group">     <button type="button" class="btn btn-danger">action</button> <button type="button" class="btn btn-danger dropdown-toggle" data-   toggle="dropdown"  aria-expanded="false">     <span class="caret"></span>     <span class="sr-only">toggle dropdown</span> </button> <ul class="dropdown-menu" role="menu">     <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> 

why selected item not loading instead of 'action' list value. working dropdown menu ? please help

you need make sure fiddle includes links / references external resources.

when "why selected item not loading instead of 'action' list value", mean it's not updating dropdown item click on? if so, want add following:

$(document).ready(function(){     $('.dropdown-toggle').dropdown();      $('.dropdown-menu li a').click(function() {         $('.btn:first-child').text($(this).text());         $('.btn:first-child').val($(this).text());     }); }); 

http://jsfiddle.net/54edxsmv/4/

what does, when click on li a tag within .dropdown-menu list, update text , value of first button .btn:first-child clicked items text.

there many ways of handling multiple dropdowns, example:

$(document).ready(function(){     $('.dropdown-toggle').dropdown();      $.each($('.btn-group'), function() {          var $dropdown = $(this);          $dropdown.find('.dropdown-menu li a').click(function() {             $dropdown.find('.btn:first-child').text($(this).text());             $dropdown.find('.btn:first-child').val($(this).text());         });     });  }); 

http://jsfiddle.net/54edxsmv/5/


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -