Best ways to display notifications with jQuery

后端 未结 5 1203
悲&欢浪女
悲&欢浪女 2020-12-23 17:57

I have a form which is a simple CRUD.

I am trying to display a cool looking success message when user enters or deletes a record. I\'ve seen this a lot around the

5条回答
  •  醉梦人生
    2020-12-23 18:32

    This should work:

    function showSnazzySuccessMessage(text)
    {
        if($("#successMessage").length < 1)
        {
            //If the message div doesn't exist, create it
            $("body").append("");
        }
        else
        {
            //Else, update the text
            $("#successMessage").html(text);
        }
        //Fade message in
        $("#successMessage").show('slow');
        //Fade message out in 5 seconds
        setTimeout('$("#successMessage").hide("slow")',5000);
    }
    

    You'll have to play with the style to get it to look the way you want, but you get the idea.

提交回复
热议问题