Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8875433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:58:26+00:00 2026-06-14T18:58:26+00:00

I have a script that I found at http://www.red-team-design.com/cool-notification-messages-with-css3-jquery , but I’m having a

  • 0

I have a script that I found at http://www.red-team-design.com/cool-notification-messages-with-css3-jquery, but I’m having a problem with my code

I’m wanting to get it to 1) hide on click, and 2) hide after 15 seconds

HTML:

<div class="warning message">It is currently past 4pm. Any orders placed between now and midnight will not be placed until 4pm tomorrow.</div>

Javascript:

var myMessages = ['info','warning','error','success']; // define the messages types
function hideAllMessages(){
    var messagesHeights = new Array(); // this array will store height for each
    for (i=0; i<myMessages.length; i++){
        messagesHeights[i] = $('.' + myMessages[i]).outerHeight(); // fill array
        $('.' + myMessages[i]).css('top', -messagesHeights[i]); //move element outside viewport
    }
}
function showMessage(type){
    hideAllMessages();
    $('.'+type).animate({top:"0"}, 500);
    setTimeout(function(){
        $('.'+type).animate({top: -$('.'+type).outerHeight()}, 500);
        hideAllMessages();
        },15000);
}
$(document).ready(function(){
    // Initially, hide them all
    hideAllMessages();
    // Show message
    for(var i=0;i<myMessages.length;i++) {showMessage(myMessages[i]);}         
    // When message is clicked, hide it
    $('.message').click(function(){              
          $(this).animate({top: -$(this).outerHeight()}, 500);
    });
});

This is getting executed by php, which I’m just inserting the following line into my code using php:

<script type='text/javascript'>
    $(document).ready(function(){
        showMessage(warning)
    });
</script>​

Now for some reason the div doesn’t hide when I click it, and it won’t hide after the 15 seconds as specified.

I’ve created a JSFiddle at http://jsfiddle.net/dpdesignz/yTaRa/1/ if anyone would mind looking to see what may be going wrong? I have a feeling it’s related to the part executed by the PHP echo, so does anyone know of another way to maybe do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:58:27+00:00Added an answer on June 14, 2026 at 6:58 pm

    You have a few errors in your code.

    First warning is not defined

    Which refers to the following:

    $(document).ready(function(){
        showMessage(warning) 
    });
    

    warning is not a set variable. Perhaps you mean this to be 'warning'.

    Secondly showMessage is not defined

    showMessage('warning');
    

    This is called before the showMessage() function is defined. You can fix this by moving this call into the other $(document).ready()

    http://jsfiddle.net/yTaRa/5/

    var myMessages = ['info','warning','error','success']; // define the messages types
    function hideAllMessages(){
        var messagesHeights = new Array(); // this array will store height for each
        for (i=0; i<myMessages.length; i++){
            messagesHeights[i] = $('.' + myMessages[i]).outerHeight(); // fill array
            $('.' + myMessages[i]).css('top', -messagesHeights[i]); //move element outside viewport
        }
    }
    function showMessage(type){
        hideAllMessages();
        $('.'+type).animate({top:"0"}, 500);
        setTimeout(function(){
            $('.'+type).animate({top: -$('.'+type).outerHeight()}, 500);
            hideAllMessages();
            },15000);
    }
    $(document).ready(function(){
        // Initially, hide them all
        hideAllMessages();
        // Show message
        for(var i=0;i<myMessages.length;i++) {showMessage(myMessages[i]);}         
        // When message is clicked, hide it
        $('.message').click(function(){              
              $(this).animate({top: -$(this).outerHeight()}, 500);
        });
        showMessage('warning');
    });
    ​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ajax image upload script which i found here http://www.fengcool.com/2009/06/ajax-form-upload-local-image-file-without-refresh/ The problem
i have this script found here http://jsfiddle.net/g4txt/ i am using this carousel http://www.thomaslanciaux.pro/jquery/jquery_carousel.htm the
I am using jRating a star rating found on http://www.myjqueryplugins.com/jquery-plugin/jrating on that same page,
I found this ajax file upload script here http://www.phpletter.com/Demo/AjaxFileUpload-Demo/ Which is supposed to add
I have just found a script we are using which has a sub that
I found an amazing typewriting effect at this website: http://www.9elements.com The header shows a
i have this jquery script that changes the color of the background instantly by
I have a script that I found online, that is trying to get the
I have script that reads remote file content and writes it to local server.
I have this script that run to fix my menu bar to the browser

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.