"Search With dropdown "
Bootstrap 3.0.0 Snippet by write2varun

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<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">
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
/* 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;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$(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);
});
});
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments:

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

Pankaj Chaurasia () - 8 years ago - Reply 0