Toggle navigation
Bootsnipp
Bootstrap
For
CSS Frameworks
Bootstrap
Foundation
Semantic UI
Materialize
Pure
Bulma
References
CSS Reference
Tools
Community
Page Builder
Form Builder
Button Builder
Icon Search
Dan's Tools
Diff / Merge
Color Picker
Keyword Tool
Web Fonts
.htaccess Generator
Favicon Generator
Site Speed Test
Snippets
Featured
Tags
By Bootstrap Version
4.1.1
4.0.0
3.3.0
3.2.0
3.1.0
3.0.3
3.0.1
3.0.0
2.3.2
Register
Login
"Succes and error"
Bootstrap 3.3.0 Snippet by
gbg933
3.3.0
jQuery
error
Preview
HTML
CSS
JS
View Full Screen
Fork
Fork this
5.8K
 
1 Fav
Post to Facebook
Tweet this
<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 ----------> <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.css"> <div class="container"> <div class="row"> <h2> Con evento click </h2> <div class="notification notification-success logged-out"> You logged out successfully! </div> <div class="notification notification-error logged-oute"> You logged out successfully! </div> <a href="#" class="btn btn-success btn-lg btn-logout"> Success </a> <a href="#" class="btn btn-danger btn-lg btn-logoute"> Error </a> </div> </div> <div class="container"> <div class="row"> <h2> Con funcion independiente </h2> <div class="notification "> You logged out successfully! </div> <a href="#" class="btn btn-success btn-lg " onclick='message("El usuario se logeo correctamente","success");'> Success </a> <a href="#" class="btn btn-danger btn-lg " onclick='message("Error - Error 303 :(","error");'> Error </a> </div> </div>
/* Notifications */ .notification{ position:fixed; top: 20px; right:0; background-color:#FF4136; padding: 20px; color: #fff; font-size:21px; display:none; } .notification-success{ background-color:#3D9970; } .notification-show{ display:block!important; } .notification-error{ background-color:#A62D26; }
$(document).ready(function() { $('.btn-logout').click(function(){ // Notification $('.notification.logged-out').removeClass('bounceOutRight notification-show animated bounceInRight'); // show notification $('.notification.logged-out').addClass('notification-show animated bounceInRight'); $('.notification.logged-out').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){ setTimeout(function(){ $('.notification.logged-out').addClass('animated bounceOutRight'); }, 800); }); }); $('.btn-logoute').click(function(){ // Notification $('.notification.logged-oute').removeClass('bounceOutRight notification-show animated bounceInRight'); // show notification $('.notification.logged-oute').addClass('notification-show animated bounceInRight'); $('.notification.logged-oute').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){ setTimeout(function(){ $('.notification.logged-oute').addClass('animated bounceOutRight'); }, 800); }); }); }); function message(msj, tipo){ //Setemos la notificacion //Removemos clases $('.notification').removeClass('notification-error'); $('.notification').removeClass('notification-succes'); //Limpiados el msj $('.notification').empty(); //Ingresamos msj $('.notification').append( msj ); // Notification $('.notification').removeClass('bounceOutRight notification-show animated bounceInRight'); // show notification $('.notification').addClass('notification-show notification-'+tipo+' animated bounceInRight'); $('.notification').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){ setTimeout(function(){ $('.notification').addClass('animated bounceOutRight'); }, 800); }); }
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76