【问题标题】:how can i make sweet2alert don't show again message?我怎样才能让 sweet2alert 不再显示消息?
【发布时间】:2021-05-02 22:23:51
【问题描述】:

如果我使用本地存储单击"<span onclick='save()'>Don't Show Again</span>",,我一直在尝试隐藏此消息,但它不起作用。我该怎么做?

<script type="text/javascript">
  if(localStorage.getItem("DontShow")) {
        $("#save").hide();
    }
    $(document).on("click", "#save", function() {
        localStorage.setItem("DontShow", "true");
    });

  Swal.fire({
            allowOutsideClick: false,
            allowEscapeKey: false,
            allowEnterKey: false,
            showCancelButton: true,
            icon: 'info',
            title: 'Title',
            html: '<div class="swal-left"><b>Text</b><br>Text</div>',

            confirmButtonColor: '#DD6B55',
            cancelButtonText: "Close",
            confirmButtonText: "<span onclick='save()'>Don't Show Again</span>",
            footer: '<a href>Why do I have this issue?</a>'
          });

  
</script>

【问题讨论】:

    标签: javascript sweetalert2


    【解决方案1】:

    在 swal.fire 函数之后添加这个

    .then((result) => {
      if (result.isConfirmed)
          'function that hides here'
    
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-03
      • 2011-01-02
      • 1970-01-01
      • 2021-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多