• toast提示 封装


    直接上代码  拿走不送!

     1 <!DOCTYPE html>
     2 <html lang="en">
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>toast</title>
     6     <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
     7     <style>
     8         .toast {
     9             position: fixed;
    10             top: 18%;
    11             left: 50%;
    12             transform: translateX(-50%);
    13             padding: 10px 20px;
    14             border-radius: 6px;
    15             color: #fff;
    16             font-size: 14px;
    17             min-width: 250px;
    18             text-align: center;
    19             display: none;
    20             z-index: 10000;
    21             border:solid 1px #fff;
    22         }
    23 
    24         .succ {
    25             background: rgb(78, 164, 78);
    26             display: block;
    27         }
    28 
    29         .fail {
    30             background: rgba(230, 0, 0, 0.6);
    31             display: block;
    32         }
    33     </style>
    34 </head>
    35 <body>
    36     <button type="button" id="btn">
    37         点击
    38     </button>
    39      <div class="toast " style="top:8%; "></div>
    40 </body>
    41 <script type="text/javascript">
    42     $('#btn').on("click",function(){
    43         toast('事件成功', 'succ',1);
    44     })
    45     //toast
    46     function toast(content, sName, fn) {
    47         $('.toast').addClass(sName);
    48         $('.toast').html(content);
    49         setTimeout(() => {
    50             $('.toast').removeClass(sName);
    51             $('.toast').html('');
    52             if (fn) {
    53                 console.log(1)
    54                 toast('事件失败', 'fail');
    55             }
    56         }, 2000);
    57     }
    58 </script>
    59 </html>
  • 相关阅读:
    微博回调接口
    vue获取微博授权URL
    生成微博授权URL接口
    微博账号注册
    微博三方登录原理讲解
    使用celery异步发送短信
    celery配置与基本使用
    友情链接
    Linux无线网络设置--wpa_supplicant的使用
    wpa_supplicant介绍与使用
  • 原文地址:https://www.cnblogs.com/xuwupiaomiao/p/13498520.html
Copyright © 2020-2023  润新知