Autohide drupal messages with jquery
Last updated on
30 April 2025
here is a small example of how can you display & and then autohide drupal messages
In your page.tpl.php put this code :)
<?php if ($show_messages && $messages): ?>
<script> $(function(){
$('#messages').hide(); //starts hidden so we have a nice fadein effect
$('#messages').fadeIn(1000); //fadein for 10000 ms
$('#messages').animate({"opacity":"hidden"},5000,function () {$(this).css({display: "none"})}); //hide it after 5000 ms.
});</script>
<div id="messages"><? print $messages; ?> </div><? endif;?>Cheers ;)
Help improve this page
Page status: Not set
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion