"Dropdown Searech EX1"
Bootstrap 3.3.0 Snippet by hongz1

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <h2>Dropdown Searech EX1</h2> <div class="row"> <div class="col-md-5"> <div class="input-group"> <div class="input-group-btn bs-dropdown-to-select-group"> <button type="button" class="btn btn-primary dropdown-toggle as-is bs-dropdown-to-select" data-toggle="dropdown" tabindex="-1"> <span data-bind="bs-drp-sel-label">Customer</span> <input type="hidden" name="country_path" data-bind="bs-drp-sel-value" value="Customer"> <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu" style=" max-height: 300px; "> <!-- Loop --> <li data-value="Customer"><a href="#">Customer </a></li> <li data-value="Vendor"><a href="#">Vendor </a></li> <li data-value="Competitor"><a href="#">Competitor </a></li> <!-- END Loop --> </ul> </div><!-- /btn-group --> <input type="text" class="form-control" aria-label="..."> <span class="input-group-btn"> <button class="btn btn-danger" type="button">Search</button> </span> </div><!-- /input-group --> </div> </div> </div>
$(document).ready(function(e){ $( document ).on( 'click', '.bs-dropdown-to-select-group .dropdown-menu li', function( event ) { var $target = $( event.currentTarget ); $target.closest('.bs-dropdown-to-select-group') .find('[data-bind="bs-drp-sel-value"]').val($target.attr('data-value')) .end() .children('.dropdown-toggle').dropdown('toggle'); $target.closest('.bs-dropdown-to-select-group') .find('[data-bind="bs-drp-sel-label"]').text($target.attr('data-value'));/*$target.text()*/ console.log($target.text()); return false; }); });

Related: See More


Questions / Comments: