美丽 警报/提示/确认对话框备选方案 jQuery.Alert.js

  • 源码大小:10.48KB
  • 所需积分:1积分
  • 源码编号:19JP-3596
  • 浏览次数:1007次
  • 最后更新:2023年06月30日
  • 所属栏目:幻灯片
我要下载
加入收藏
本站默认解压密码:19jp.com 或 19jp_com

简介

一个JavaScript弹出窗口替代方案,可以帮助您创建漂亮且可自定义的弹出框,用于提醒、确认或拒绝某些内容,或提示用户获取更多信息。

响应迅速,易于实施

主要功能:

  • 支持HTML内容。
  • 自定义强调文本。
  • 自定义确认/取消按钮。
  • 确认并取消回拨。
  • 自定义输入类型。
  • 支持jQuery方法链接。

如何使用它:

1.将jQuery.alert.js插件的文件添加到HTML页面。

  1. <link href="jquery.alert.css" rel="stylesheet" />
  2. <script src="/path/to/cdn/jquery.min.js"></script>
  3. <script src="jquery.alert.min.js"></script>

2.创建一个自定义警报对话框。

  1. $.alert('An Alert Dialog By jQueryScript',{
  2. em:'Emphasized Text',
  3. title:'Alert Dialog'
  4. })

3.创建一个自定义的确认对话框。

  1. $.confirm('Are You Sure To Delete This Entry?',{
  2. em:'Emphasized Text',
  3. title:'Delete!',
  4. callEvent:function(){
  5. $.alert('Deleted!')
  6. },
  7. cancelEvent:function(){
  8. $.alert('Canceled')
  9. },
  10. cancelButton:'No!'
  11. })

4.创建一个自定义提示对话框。

  1. $.prompt('Try To Type 1234',{
  2. title:'Login Form',
  3. callEvent:function(val){
  4. if(val==1234) $.alert('Invalid Password');
  5. else $.alert('Logged In');
  6. },
  7. input:'password',
  8. confirmButton:'Log In'
  9. })

5.该插件还支持jQuery方法链接。

  1. $('.colorChange-btn').click(function() {
  2. $("#item-box").stop().animate(
  3. {"margin-left":"500px"},1000
  4. ).animate(
  5. {"margin-left":"0"},300
  6. ).delay(300).alert('Another Dialog',
  7. {
  8. callEvent:function(){
  9. $("#item-box").stop().animate(
  10. {"margin-left":"500px"},1000
  11. ).animate(
  12. {"margin-left":"0"},300
  13. )
  14. }
  15. });
  16. })

6.所有默认配置。

  1. {
  2.  
  3. // dialog title
  4. title:'Title',
  5.  
  6. // emphasized Text
  7. em:'',
  8.  
  9. // fired when you click the confirm button
  10. callEvent:null,
  11.  
  12. // reverse button position
  13. buttonReverse: false,
  14.  
  15. // fired when you click the cancel button
  16. cancelEvent:null,
  17.  
  18. // custom button text
  19. confirmButton:'Okay',
  20. cancelButton:'Cancel',
  21.  
  22. // input type
  23. input:'text',
  24.  
  25. // input value
  26. value:null
  27. }

预览截图