Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

javascript message dissapear

im wondering how i can make a message dissapear on this script after 5 seconds? Im kinda new at alot of this.

<script type="text/javascript">
    if (localStorage) {

        var UserName = localStorage.getItem("UserName");
        document.getElementById('notes').value = UserName;
    }

    function SaveToOfflineStorage() {
        try {
            if (localStorage) {
                var txtValue = document.getElementById('notes').value;
                localStorage.setItem("UserName", txtValue);
                document.getElementById('msg').innerHTML = ' - Saved Successfully!';
                setTimeout(msg, 5000);

            }

        }
        catch (err) {
            document.getElementById('msg').innerHTML = err.Description;
        }
    }

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can do it like this,

function SaveToOfflineStorage() {
    try {
        if (localStorage) {
            var txtValue = document.getElementById('notes').value;
            localStorage.setItem("UserName", txtValue);
            document.getElementById('msg').innerHTML = ' - Saved Successfully!';
            setTimeout(() => {
                document.getElementById('msg').innerHTML = '';
            }, 5000);

        }

    } catch (err) {
        document.getElementById('msg').innerHTML = err.Description;
    }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading