JSFiddle - React, Tailwind, and code Playground

HTML

<div id="notification-1">This is notification 1</div>
<div id="notification-2">This is notification 2</div>

JavaScript

function Notification(type)
{
    var nID;
    switch(type)
    {
        case 'success' :
            nID = 'notification-1';
        break;
        case 'error' :
            nID = 'notification-2';
        break;           
    }
    $('#' + nID).delay(5000).fadeOut(200, function()
    {
        if(type == 'success')
        {
            alert('Success');   
        }
    });
}

$(document).ready(function()
{
    Notification('success');
});