限时优惠活动
亲爱的苦力吧用户,我们为了回馈新老用户一直以来的鼎力支持,即日起(2025-02-06至2025-03-06)凡是购买苦力吧VIP/充值K币的新老用户,都直接可获得买一送一的优惠馈赠。例如:购买一个月的VIP会员可直接获得两个月的VIP会员;充值100K币可直接获得200K币,以此类推!有任何疑问可联系在线客服,感谢各位用户对苦力吧素材的信任与厚爱,我们将一如既往的给大家上新更多优质的素材源码,祝大家开工大吉、工作顺利、心想事成。

基于bootstrap可自定义文字及风格位置的弹出层插件

所属分类: 网页特效-弹出层    2023-12-26 09:42:52

基于bootstrap可自定义文字及风格位置的弹出层插件 ie兼容6
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

基于bootstrap可自定义文字及风格位置的弹出层插件(共3个文件)

    • index.html

使用方法

  • code
  • source
  1. document.querySelector('#create-toast').addEventListener('click', function() {
  2. document.querySelector('#toast-container').classList.remove('top-0','end-0','bottom-0','start-0');
  3. var content = (document.querySelector('input[name=content]').value != '')
  4. ? document.querySelector('input[name=content]').value
  5. : 'Lorem ipsum dolor sit amet';
  6. var type = (document.querySelector('select[name=type]').value != '')
  7. ? document.querySelector('select[name=type]').value
  8. : 'success';
  9. var position = (document.querySelector('select[name=position]').value != '')
  10. ? document.querySelector('select[name=position]').value.split(',')
  11. : ['top-0','end-0'];
  12. showToast(content, type, position);
  13. });
  14. function showToast(content, type, position) {
  15. var delay = 15000;
  16. position.forEach((el) => {
  17. document.querySelector("#toast-container").classList.add(el);
  18. });
  19. var html = `<div class="toast align-items-center text-white bg-${type} border-0" role="alert" aria-live="assertive" aria-atomic="true"><div class="d-flex"><div class="toast-body h6 p-3 m-0">${content}</div><button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button></div></div>`;
  20. var toast = htmlToElement(html);
  21. var toastContainer = document.querySelector("#toast-container");
  22. toastContainer.appendChild(toast);
  23. var toast = new bootstrap.Toast(toast, {delay:delay, animation:true});
  24. toast.show();
  25. setTimeout(() => toast.remove(), delay + 15000);
  26. }
  27. function htmlToElement(html) {
  28. var template = document.createElement('template');
  29. html = html.trim();
  30. template.innerHTML = html;
  31. return template.content.firstChild;
  32. }
document.querySelector('#create-toast').addEventListener('click', function() {
    document.querySelector('#toast-container').classList.remove('top-0','end-0','bottom-0','start-0');

    var content = (document.querySelector('input[name=content]').value != '') 
        ? document.querySelector('input[name=content]').value 
        : 'Lorem ipsum dolor sit amet';

    var type = (document.querySelector('select[name=type]').value != '') 
        ? document.querySelector('select[name=type]').value 
        : 'success';

    var position = (document.querySelector('select[name=position]').value != '') 
        ? document.querySelector('select[name=position]').value.split(',')
        : ['top-0','end-0'];

    showToast(content, type, position);
});

function showToast(content, type, position) {
    var delay = 15000;
    position.forEach((el) => {
        document.querySelector("#toast-container").classList.add(el);
    });
    var html = `<div class="toast align-items-center text-white bg-${type} border-0" role="alert" aria-live="assertive" aria-atomic="true"><div class="d-flex"><div class="toast-body h6 p-3 m-0">${content}</div><button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button></div></div>`;
    var toast = htmlToElement(html);
    var toastContainer = document.querySelector("#toast-container");
    toastContainer.appendChild(toast);
    var toast = new bootstrap.Toast(toast, {delay:delay, animation:true});
    toast.show();
    setTimeout(() => toast.remove(), delay + 15000);
}

function htmlToElement(html) {
    var template = document.createElement('template');
    html = html.trim();
    template.innerHTML = html;
    return template.content.firstChild;
}

站长提示:
1. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 弹出层

jquery支持拖拽移动的自定义弹出层插件

一个简单而轻量级的弹出窗口插件,用于为提醒、确认对话框和弹出窗口创建可自定义、可拖动的对话框弹出窗口。
  弹出层
 8312  0

jquery带多彩动画特效的弹出提示窗口插件

一款纸屑合成特效弹出层特效代码,点击关闭弹出层后,再次触发纸屑慢慢消失动画效果。
  弹出层
 2281  0

jquery带倒计时功能的自定义弹出框插件

一款带倒计时自动关闭的弹出层插件,可自定义倒计时时间、确认/取消按钮以及弹出框标题及内容。。
  弹出层
 7309  0

jquery支持移动端弹出图片查看器插件

一款超实用的弹出图片查看器,点击图片可弹出大图,且支持自动关联上一张、下一张图片,可左右切换,还支持按键盘ESC/左右按键控制。
  弹出层
 1197  0

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论