Search code examples
jquerytoastr

How to close all toastr messages on click an anchor using jQuery?


I use toastr to toast notifications in my page. How can I close all open messages if a link is clicked.


Solution

  • check if you have the the toastr global object defined.

    console.log(!!window.toastr);
    

    if you have it you can use toastr.clear();

    $('a.myLinkClass').click(function() {
       window.toastr.clear();
    });