"Close Panel Effects"
Bootstrap 3.1.0 Snippet by pileOgames

<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.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 ----------> <head> <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"> </head> <div class="container"> <div class="row"> <div class="jumbotron"> <h2>Close Panel With Button</h2> <p>You can use jQuery Effects to close away you Panel using the data-effect and name it how you want to.</p> </div> </div> <div class="row"> <div class="col-md-3 col-sm-6 col-xs-6"> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">Using Fade Out</h3> <!-- Watch Out: Here We must use the effect name in the data tag--> <span class="pull-right clickable" data-effect="fadeOut"><i class="fa fa-times"></i></span> </div> <div class="panel-body"> Panel content </div> <div class="panel-footer"> Panel footer </div> </div> </div> <div class="col-md-3 col-sm-6 col-xs-6"> <div class="panel panel-info"> <div class="panel-heading"> <h3 class="panel-title">Using Slide Up</h3> <!-- Watch Out: Here We must use the effect name in the data tag--> <span class="pull-right clickable" data-effect="slideUp"><i class="fa fa-times"></i></span> </div> <div class="panel-body"> Panel content </div> <div class="panel-footer"> Panel footer </div> </div> </div> <div class="col-md-3 col-sm-6 col-xs-6"> <div class="panel panel-warning"> <div class="panel-heading"> <h3 class="panel-title">Using Remove</h3> <!-- Watch Out: Here We must use the effect name in the data tag--> <span class="pull-right clickable" data-effect="remove"><i class="fa fa-times"></i></span> </div> <div class="panel-body"> Panel content </div> <div class="panel-footer"> Panel footer </div> </div> </div> <div class="col-md-3 col-sm-6 col-xs-6"> <div class="panel panel-warning"> <div class="panel-heading"> <h3 class="panel-title">Using Hide</h3> <!-- Watch Out: Here We must use the effect name in the data tag--> <span class="pull-right clickable" data-effect="hide"><i class="fa fa-times"></i></span> </div> <div class="panel-body"> Panel content </div> <div class="panel-footer"> Panel footer </div> </div> </div> </div> </div>
.panel-heading span { margin-top: -26px; font-size: 15px; margin-right: -12px; } .clickable { background: rgba(0, 0, 0, 0.15); display: inline-block; padding: 6px 12px; border-radius: 4px; cursor: pointer; }
$(function(){ $('.clickable').on('click',function(){ var effect = $(this).data('effect'); $(this).closest('.panel')[effect](); }) })

Related: See More


Questions / Comments: