How to change Chevron Up and Down using Bootstrap

Manideepgoud
Posted by Manideepgoud under Bootstrap category on | Points: 40 | Views : 768
Here we are going to see how to change the chevron icon up and down using bootstrap, we have used jquery and javascript to change icons.
<!DOCTYPE html>
<html>
<head>
<title>Angularjs Application</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script>
var change = true;
$(document).ready(function () {
$('[data-toggle=offcanvas]').click(function () {
$('.row-offcanvas').toggleClass('active');
});
});

function find() {
$("#caret1").toggleClass("glyphicon-chevron-up", change);
$("#caret1").toggleClass("glyphicon-chevron-down", !change);
change = !change
}
</script>
</head>
<body>
<p style="color:blue;">Chevron Up and Chevron Down</p>
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<li onclick="find()">
<a href="#" data-toggle="collapse" data-target="#sub1">Click Here<small><span style="float:right" id="caret1" class="glyphicon glyphicon-chevron-down"></span></small></a>
</li>
<ul class="nav collapse" id="sub1">
<li>
<a href="#">Hai</a>
</li>
</ul>
</ul>

</div>
</div>
</body>
</html>

Comments or Responses

Login to post response