Below code snippet helps you populate Alert messages in a Div which has a delay.
This message will fade in and fade out after clicking on the button.
Successful Alert !!!
Failure Alert !!!
Warning Alert !!!
Script
- $( "#success-btn" ).click(function() {
- $( "div.success" ).fadeIn( 300 ).delay( 1500 ).fadeOut( 400 );
- });
- $( "#failure-btn" ).click(function() {
- $( "div.failure" ).fadeIn( 300 ).delay( 1500 ).fadeOut( 400 );
- });
- $( "#warning-btn" ).click(function() {
- $( "div.warning" ).fadeIn( 300 ).delay( 1500 ).fadeOut( 400 );
- });
HTML
- <p>
- <button id="success-btn">Success</button>
- <button id="failure-btn">Failure</button>
- <button id="warning-btn">Warning</button>
- </p>
- <div class="alert-box success">Successful Alert !!!</div>
- <div class="alert-box failure">Failure Alert !!!</div>
- <div class="alert-box warning">Warning Alert !!!</div>
CSS
- .alert-box {
- padding: 15px;
- margin-bottom: 20px;
- border: 1px solid transparent;
- border-radius: 4px;
- }
- .success {
- color: #3c763d;
- background-color: #dff0d8;
- border-color: #d6e9c6;
- display: none;
- }
- .failure {
- color: #a94442;
- background-color: #f2dede;
- border-color: #ebccd1;
- display: none;
- }
- .warning {
- color: #8a6d3b;
- background-color: #fcf8e3;
- border-color: #faebcc;
- display: none;
- }
No comments:
Post a Comment