This time I will share jQuery Plugin and tutorial about Responsive Modal-style Alert Dialog With jQuery – alert.js, hope it will help you in programming stack.
alert.js is a minimal (less than 1kb) jQuery plugin which helps create a responsive, cross-browser, modal-style alert dialog with an animated background overlay on the html page.
How to use it:
1. Insert jQuery library, alert.css
, and alert.js
into the page.
1 |
< link href = "alert.jquery.css" rel = "stylesheet" > |
2 |
< script src = "//code.jquery.com/jquery.min.js" ></ script > |
3 |
< script src = "alert.jquery.js" ></ script > |
2. You might need a trigger element to toggle the alert dialog (OPTIONAL).
1 |
< button id = "trigger" >ALERT</ button > |
3. Initialize the alert dialog and define your own alert message as follows:
2 |
attachAfter: '#trigger' , |
3 |
title: 'You have reached the limit or your quota!' , |
4. Show the alert dialog on the page.
5. If you want to enable the trigger element to toggle the alert dialog.
01 |
$( '#trigger' ).click( function (){ |
03 |
attachAfter: '#trigger' , |
04 |
title: 'You have reached the limit or your quota!' , |
05 |
confirmText: 'Accept' , |
6. Override the default styles of the alert dialog as you seen in the alert.css
:
08 |
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)" ; |
09 |
filter: alpha(opacity= 50 ); |
13 |
filter: alpha(opacity= 50 ); |
24 |
box-sizing: border-box; |
26 |
box-shadow: 0px 0px 2px 2px #6B6B6B ; |
32 |
padding : 0px 0px 5px 5px ; |
42 |
#alert_actions button { |
46 |
text-transform : uppercase ; |
48 |
-khtml-border-radius: 3px ; |
49 |
-o-border-radius: 3px ; |
51 |
-webkit-border-radius: 3px ; |
52 |
-moz-border-radius: 3px ; |
55 |
#alert_actions button. blue { background : #007aff ; } |
7. Customize the template of the alert dialog.
02 |
attachAfter: '#trigger' , |
03 |
title: 'You have reached the limit or your quota!' , |
05 |
<p> This a template to provide some info to the customer <p> |
06 |
<p> <strong> Alert: </strong> Read it carefully </p> , |
07 |
confirmText: 'Accept' , |
Changelog:
2018-07-03
- Fixed ‘mouseup’ event name
2018-06-30
2018-05-16
2018-02-06
This awesome jQuery plugin is developed by BanNsS1. For more Advanced Usages, please check the demo page or visit the official website.