"Search With dropdown "
Bootstrap 3.0.0 Snippet by write2varun

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.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"> <div class="row"> <nav class="navbar navbar-default"> <div class="nav nav-justified navbar-nav"> <form class="navbar-form navbar-search" role="search"> <div class="input-group"> <div class="input-group-btn"> <button type="button" class="btn btn-search btn-default dropdown-toggle" data-toggle="dropdown"> <span class="glyphicon glyphicon-search"></span> <span class="label-icon">Search</span> <span class="caret"></span> </button> <ul class="dropdown-menu pull-left" role="menu"> <li> <a href="#"> <span class="glyphicon glyphicon-user"></span> <span class="label-icon">Search By User</span> </a> </li> <li> <a href="#"> <span class="glyphicon glyphicon-book"></span> <span class="label-icon">Search By Organization</span> </a> </li> </ul> </div> <input type="text" class="form-control"> <div class="input-group-btn"> <button type="button" class="btn btn-search btn-default"> GO </button> </div> </div> </form> </div> </nav> </div> </div>
/* nav bar search box - drop down menu button */ .navbar .navbar-search .dropdown-menu { min-width: 25px; } .dropdown-menu .label-icon { margin-left: 5px; } .btn-outline { background-color: transparent; color: inherit; transition: all .5s; }
$(function(){ $(".input-group-btn .dropdown-menu li a").click(function(){ var selText = $(this).html(); //working version - for single button // //$('.btn:first-child').html(selText+'<span class="caret"></span>'); //working version - for multiple buttons // $(this).parents('.input-group-btn').find('.btn-search').html(selText); }); });

Related: See More


Questions / Comments:

i am trying to put this code in my site but dropdown is not working ? please help

Pankaj Chaurasia () - 3 years ago - Reply 0